cjacks Posted May 21, 2006 Share Posted May 21, 2006 I am having trouble getting this script to work.I need it to retrieve a mysql record in to a form to allow users to update thier information. The update would be based on email and password entered on a diffrerent form, query sent to database, current results retrieved in to form that the user sees and can update from there. Any help on this greatly appreciated. I am sure it is basic for most of you, but I am not good with php at all. Thanks!<?phpinclude("include/dbconnect.php");$email = $_POST['email'];$pword = $_POST['pword'] ;if ( $email && $pword ) { $result = mysql_query("SELECT * FROM $table WHERE email=$email",$db); $myrow = mysql_fetch_array($result); ?> <form method="post" action="update.php"> <table width="380" border="0" cellspacing="1" cellpadding="1"> <tr> <td> <input type="hidden" name="email" value="<?php echo $myrow["email"]?>"> Firstname:</td> <td> <input type="Text" name="firstname" size="35" value="<?php echo $myrow["firstname"]?>"> </td> </tr> <tr> <td>Lastname:</td> <td> <input type="Text" name="lastname" size="35" value="<?php echo $myrow["lastname"]?>"> </td> </tr> <tr> <td>Street:</td> <td> <input name="street" type="text" value="<?php echo $myrow["street"]?>" size="35"> </td> </tr> <tr> <td>City:</td> <td> <input name="city" type="Text" id="city" value="<?php echo $myrow["city"]?>"> </td> </tr> <tr> <td>State:</td> <td> <input name="state" type="Text" id="state" value="<?php echo $myrow["state"]?>"> </td> </tr> <tr> <td>Zip:</td> <td> <input name="zip" type="Text" id="zip" value="<?php echo $myrow["zip"]?>"> </td> </tr> <tr> <td>Telephone:</td> <td><input name="home" type="text" id="home" value="<?php echo $myrow["home"]?>"></td> </tr> <tr> <td>Email:</td> <td> <input type="Text" name="email" size="35" value="<?php echo $myrow["email"]?>"> </td> </tr> <tr> <td>Password</td> <td> <input type="Text" name="pword" size="35" value="<?php echo $myrow["pword"]?>"> </td> </tr> <tr> <td>Birthday (Day/Month/Year)</td> <td> <input name="bday" type="text" id="bday" value="<?php echo $myrow["bday"]?>" size="2" maxlength="2"> / <input name="bmonth" type="text" id="bmonth" value="<?php echo $myrow["bmonth"]?>" size="2" maxlength="2"> / <input name="byear" type="text" id="byear" value="<?php echo $myrow["byear"]?>" size="4" maxlength="4"></td> </tr> </table> <input type="Submit" name="update" value="Update information"> </form> <? $sql = "UPDATE $table SET firstname='$firstname',lastname='$lastname',street='$street',city='$city',state='$state',zip='$zip',email='$email',home='$home',bday='$bday',bmonth='$bmonth',byear='$byear',pword='$pword' WHERE email=$email";$result = mysql_query($sql);echo "<br><br>Address book updated.\n"; } elseif ($update); { ?> <form method="post" action="<?php echo $PHP_SELF?>"> <table width="380" border="0" cellspacing="1" cellpadding="1"> <tr> <td> Email:</td> <td> <input name="email" type="Text" id="email" size="35"> </td> </tr> <tr> <td>Passsword:</td> <td> <input name="pword" type="Text" id="pword" size="35"> </td> </tr> </table> <input type="Submit" name="submit" value="Enter information"> </form><?}?> Quote Link to comment https://forums.phpfreaks.com/topic/10120-help-with-database-update/ Share on other sites More sharing options...
.josh Posted May 21, 2006 Share Posted May 21, 2006 you expect help when:a) you didn't bother to be clear as to what your script is doing , versus what you want it to be doing. b) you didn't bother to list any errors. c) you didn't bother to post your code in the code tags, specifying what parts of that are what files etc... Quote Link to comment https://forums.phpfreaks.com/topic/10120-help-with-database-update/#findComment-37702 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.