ashrobbins87 Posted April 1, 2009 Share Posted April 1, 2009 I am currently building the user management section of my site, and I am at the editing users stage. I have a popup which takes the id of a user from MySQL database and populates textfields with their info. I then want the user to be able to alter these textfields and send the new values to the database. Sounds simple enough but.... I can get the popup to pass the id number, but not the altered text from the txt fields. The script sending the data is below... <?php if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $id = $_GET["i"]; $mysqli = mysqli_connect("localhost","root","Cadbury5","opp_group"); $getDetails_sql = "SELECT * FROM cms_users where id='".$id."'"; $getDetails_res = mysqli_query($mysqli, $getDetails_sql)or die(mysqli_error()); if ($getDetails_res) { $row = mysqli_fetch_assoc($getDetails_res); $f = $row['firstname']; $s = $row['surname']; $u = $row['username']; $p = $row['password']; } else { printf("Could not retreive records: %s\n", mysqli_error($mysqli)); } mysqli_close($mysqli); } echo "<h2>".$f." ".$s."</h2>"; ?> <form method="post" action="user.php"> <?php echo " <table> <tr><td>First Name: </td><td><input type=\"text\" name=\"firstname\" size=\"20\" value=\"".$f."\" /></tr> <tr><td>Surname: </td><td><input type=\"text\" name=\"surname\" size=\"20\" value=\"".$s."\" /></tr> <tr><td>Username: </td><td><input type=\"text\" name=\"username\" size=\"20\" value=\"".$u."\" /></tr> <tr><td>New Password: </td><td><input type=\"text\" name=\"newpassword\" size=\"20\" value=\"Enter New Password\" /></tr> <tr><td>Re-enter Password: </td><td><input type=\"text\" name=\"confirmpassword\" size=\"20\" value=\"Confirm New Password\" /></tr> </table></form> <br/><br/> "; $new_f = $_POST['firstname']; $new_s = $_POST['surname']; $new_u = $_POST['username']; $new_p = $_POST['newpassword']; $conf_p = $_POST['confirmpassword']; echo"<table> <tr> <td><input type=\"submit\" name=\"update\" value=\"Update User\" onclick=\"javascript:eventWindow('cms/updateuser.php?i=".$id."&f=".$new_f."');\"></td> <td><input type=\"button\" name=\"delete\" value=\"Delete\" onclick=\"javascript:eventWindow('cms/deletevalidation.php?i=".$id."');\"></td> </tr> </table>"; ?> and this is the code receving the data. <php $id = $_GET["i"]; $f = $_GET["f"]; echo $id; echo $f; ?> at the moment I'm just trying to echo the variables that are being passed to the new page, to make sure that they are being populated. Any help please???? Quote Link to comment https://forums.phpfreaks.com/topic/152081-passing-multiple-variables-to-javascript-popup/ Share on other sites More sharing options...
premiso Posted April 1, 2009 Share Posted April 1, 2009 Not sure if this is just a typo. On the page receiving: <?php // you were missing the ? here $id = $_GET["i"]; $f = $_GET["f"]; echo $id; echo $f; ?> See if that gets you better results. Quote Link to comment https://forums.phpfreaks.com/topic/152081-passing-multiple-variables-to-javascript-popup/#findComment-798689 Share on other sites More sharing options...
ashrobbins87 Posted April 1, 2009 Author Share Posted April 1, 2009 Ah yeah sorry that was just a typo when typing onto the forum. The code for that page is much bigger but none of it relates to the php. Thanks though! Quote Link to comment https://forums.phpfreaks.com/topic/152081-passing-multiple-variables-to-javascript-popup/#findComment-798698 Share on other sites More sharing options...
ashrobbins87 Posted April 2, 2009 Author Share Posted April 2, 2009 Anyone have any ideas? I cant work out how to give $new_f a value. I'm trying to use the $_POST[firstname'] value, which should be whatever is inside the textfield right? Quote Link to comment https://forums.phpfreaks.com/topic/152081-passing-multiple-variables-to-javascript-popup/#findComment-799298 Share on other sites More sharing options...
PHP Monkeh Posted April 2, 2009 Share Posted April 2, 2009 It won't work because the form hasn't actually been submitted, you've basically replaced the submit button with an onclick function so no form data is being sent. I don't have a suggestion on how to fix it or what you can do instead though I'm afraid - just thought I'd point that out. Quote Link to comment https://forums.phpfreaks.com/topic/152081-passing-multiple-variables-to-javascript-popup/#findComment-799355 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.