|
|
|
|
![]() ![]() |
Feb 5 2008, 12:06 PM
Post
#1
|
|
|
Advanced Member Group: Members Posts: 130 Joined: 19-January 08 From: Zagreb/Croatia Member No.: 27,735 |
While trying to make password recovery script for "bhupinunder" i run into a problem...
i made this: CODE <?php $dbh = mysql_connect('localhost','jaskaran_gc','gc') or die ("Cannot Connect: " . mysql_error()); mysql_select_db('jaskaran_gc',$dbh); ?> <form method=post action=restore.php?recover=answer> <?php print"Email:</td><td><input type=text name=email></td></tr>";?> <P><INPUT TYPE=submit VALUE=Submit!></P></form> <?php if ($recover=answer) print"$email"; ?> and it doesn't print anything...but if i put it like this CODE <?php $dbh = mysql_connect('localhost','jaskaran_gc','gc') or die ("Cannot Connect: " . mysql_error()); mysql_select_db('jaskaran_gc',$dbh); ?> <form method=post action=restore.php?recover=answer> <?php print"Email:</td><td><input type=text name=email></td></tr>";?> <P><INPUT TYPE=submit VALUE=Validate it!></P></form> <?php if ($recover=answer) print"ssss"; ?> it just shows that form and prints QUOTE ssss how do i make it that i type email and click submit that the email is stored in "$email" if someone help me with that i don't think that i'll have any problems storing it in mysql! pls respond |
|
|
|
Feb 5 2008, 05:37 PM
Post
#2
|
|
|
Premium Member Group: [HOSTED] Posts: 367 Joined: 16-February 06 From: Kolkata, India Member No.: 11,322 |
email is the name of the field in the form, correct? Depending on the HTTP method of submission you are using for the form, you can retrieve the values as:-
$_GET['email'] for GET method $_POST['email'] for POST method |
|
|
|
Feb 5 2008, 09:28 PM
Post
#3
|
|
|
the Q Group: [HOSTED] Posts: 1,017 Joined: 13-July 05 From: Lithuania, Vilnius Member No.: 7,059 |
It's one of the worst things I ever saw in a while, but anyway, I just fixed some things, it might work, I didn't test anything by myself, but I guess it should work, even though I think you're still learning and are just practicing, this is why I just fixed some stuff.
CODE <?php
$dbh = mysql_connect('localhost','jaskaran_gc','gc') or die("Cannot Connect: " . mysql_error()); mysql_select_db('jaskaran_gc',$dbh); ?> <form method="post" action="restore.php?recover=answer"> <tr><td>Email:</td><td><input type="text" name="email"></td></tr> <p><input type="submit" value="Submit!"></p> </form> <?php if ($_GET['recover'] == 'answer') echo $_POST['email']; ?> |
|
|
|
Feb 5 2008, 10:18 PM
Post
#4
|
|
|
Advanced Member Group: Members Posts: 130 Joined: 19-January 08 From: Zagreb/Croatia Member No.: 27,735 |
CODE <?php $dbh = mysql_connect('localhost','jaskaran_gc','gc') or die("Cannot Connect: " . mysql_error()); mysql_select_db('jaskaran_gc',$dbh); ?> <form method="post" action="restore.php?recover=answer"> <tr><td>Email:</td><td><input type="text" name="email"></td></tr> <tr><td>pass:</td><td><input type="password" name="pass"></td></tr> <p><input type="submit" value="Submit!"></p> </form> <?php if ($_GET['recover'] == 'answer') mysql_query("update users set userpass=$_POST['pass'] where email=$_POST['email']") or die(mysql_error()); ?> whats wrong now?(i should have asked from the start for someone to solve it now now when no one will answer) Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/jaskaran/public_html/restore.php on line 11 This post has been edited by Eggie: Feb 5 2008, 11:06 PM |
|
|
|
Feb 6 2008, 04:44 AM
Post
#5
|
|
|
Premium Member Group: [HOSTED] Posts: 367 Joined: 16-February 06 From: Kolkata, India Member No.: 11,322 |
Use $_POST outside of the double quotes.
CODE if ($_GET['recover'] == 'answer') mysql_query("update users set userpass=" . $_POST['pass'] . "where email=" . $_POST['email']) or die(mysql_error());
This post has been edited by turbopowerdmaxsteel: Feb 6 2008, 04:49 AM |
|
|
|
Feb 6 2008, 06:48 AM
Post
#6
|
|
|
Advanced Member Group: Members Posts: 130 Joined: 19-January 08 From: Zagreb/Croatia Member No.: 27,735 |
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'email=jurica@mail.com' at line 1
|
|
|
|
Feb 6 2008, 07:07 AM
Post
#7
|
|
|
Advanced Member Group: Members Posts: 130 Joined: 19-January 08 From: Zagreb/Croatia Member No.: 27,735 |
solved again
CODE mysql_query("UPDATE users SET userpass = '".md5($_POST['pass'])."' WHERE email = '".$_POST['email']."'") or die(mysql_error()); pls put [SOLVED] in the topic name(and delete this) |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 30th August 2008 - 04:06 PM |