alwaysdani Posted February 4, 2007 Share Posted February 4, 2007 Anyways, I want it to save the information in the text boxes without leaving them blank, but each time I add $.. = $_POST['..']; it still does not show/save in the text box. Also, I'm trying to make it to wear all fields are required to be filled in, other wise it will not save the data. <? include "header.php"; $sql = mysql_query("SELECT username, email, password, accounttype, rank FROM accounts WHERE id='$sid'")or die(mysql_error()); $row = mysql_fetch_assoc($sql); $email = $_SESSION['email']; $password = $_SESSION['password']; echo "<b>Homepage</b><br> Alright $name.. Dani has been abusing you by working on stuff you can't see. C: Anyways, I threw this in real quick for you guys to change your information. Don't abuse it please, I haven't made it bomb proof. But anyways, I need to go now, edit this tomorrow.<br><br>"; ?> <form action="update.php" method="post"> Name: <input type="text" name="name" size="20" value="<? echo $name; ?>"><br><br> E-mail: <input type="text" name="email" size="20" value="<? echo $email; ?>"><br><br> Password: <input type="password" name="password" size="20" value="<? echo $password; ?>"><br><br> <input type="submit" value="Submit" name="submit"></form> <? include 'footer.php'; ?> This is the page in which the form leads to. Update.php <?php include "header.php"; $email = $_POST['email']; $password = $_POST['password']; function display_form(){ print<<<HERE <form action="register2.php" method="post"> Username: <input type="text" name="username" size="20"><br><br> Password: <input type="password" name="password" size="20"><br><br> E-mail: <input type="text" name="email" size="20"><br><br> Name: <input type="text" name="name" size="20"><br><br> <input type="submit" value="Submit" name="submit"> </form> HERE; } // end function // Get Sandy's record from the "example" table $result = mysql_query("UPDATE accounts SET name='$name', password='$password', email='$email' WHERE id='$sid'") or die(mysql_error()); $result = mysql_query("SELECT * FROM accounts WHERE id='$sid'") or die(mysql_error()); // get the first (and hopefully only) entry from the result $row = mysql_fetch_array( $result ); echo "Information has successfully be saved!<br>"; } if ((!$username) || (!$password) || (!$email) || (!$name)){ echo "<b>Error!</b><br>You must fill in all fields to continue!<br><br>"; display_form(); include 'footer.php'; exit; include 'home2.php'; ?> Mreh, I'm so confused. I need help please. D: Link to comment https://forums.phpfreaks.com/topic/36990-update-query/ Share on other sites More sharing options...
tauchai83 Posted February 4, 2007 Share Posted February 4, 2007 try this: i just use the simplest way to try if ($Submit){ // Get Sandy's record from the "example" table $result = mysql_query("UPDATE accounts SET name='$name', password='$password', email='$email' WHERE id='$sid'") or die(mysql_error()); ......... ......... } for the data validation, u can use javarcript or php to validate it...example.. if($email==''){ echo "please fill up the email field"; } regards, chai Link to comment https://forums.phpfreaks.com/topic/36990-update-query/#findComment-176590 Share on other sites More sharing options...
alwaysdani Posted February 7, 2007 Author Share Posted February 7, 2007 Hm, it is now not changing the information in the database. :/ All that it will show are the errors and successes, but it won't change the info. Link to comment https://forums.phpfreaks.com/topic/36990-update-query/#findComment-179531 Share on other sites More sharing options...
tauchai83 Posted February 8, 2007 Share Posted February 8, 2007 please post your latest code that you did here. See whether i can help. Link to comment https://forums.phpfreaks.com/topic/36990-update-query/#findComment-179748 Share on other sites More sharing options...
alwaysdani Posted February 12, 2007 Author Share Posted February 12, 2007 <?php include "header.php"; $name = $_POST['name']; $email = $_POST['email']; $password = $_POST['password']; $description = $_POST['description']; if ($Submit){ // Get Sandy's record from the "example" table $result = mysql_query("UPDATE accounts SET name='$name', password='$password', email='$email' WHERE id='$sid'") or die(mysql_error()); } if($email==''){ echo "Please fill in all fields to continue!"; } $result = mysql_query("SELECT * FROM accounts WHERE id='$sid'") or die(mysql_error()); // get the first (and hopefully only) entry from the result $row = mysql_fetch_array( $result ); echo "Information has successfully be saved!<br>"; include 'home2.php'; ?> I'd like it to update Email, Name, Password, and Description. Link to comment https://forums.phpfreaks.com/topic/36990-update-query/#findComment-182340 Share on other sites More sharing options...
tauchai83 Posted February 12, 2007 Share Posted February 12, 2007 OK. What error msg that you get? please state as well. Did the updated data go into DB? and finally, there is an error: $row = mysql_fetch_array( $result ); change to $row=mysql_fetch_assoc($result); $name=$row['name']; $email=$row['email']; $password=$row['password']; $desc=$row['description']; //build a table for better look echo $name; .................. .................. thanks Link to comment https://forums.phpfreaks.com/topic/36990-update-query/#findComment-182555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.