phatgreenbuds Posted November 5, 2018 Share Posted November 5, 2018 Its been a while since I have played with this stuff. Trying to get back into it and doing pretty well catching up but I am struggling with something that should be simple. I am able to pull data from MySQL back into my form field respective to the user, but when I try to update that field I get a blank page. If this is something stupid I am doing wrong please nudge me in the right direction. <?php require('Includes/initialize.php'); $page_title = 'Test'; include_once('Includes/header.php'); // Query Stuff if(isset($_POST['update'])) { // //this is where I expect to see the updated name. Instead its just blank. // echo $_POST['first_name']; } else { if(is_post_request()){ //function to see if its a post from the previous page $uname = $_POST['username']; $pword = $_POST['password']; $result = mysqli_query($db, "SELECT * FROM SubInfo WHERE email='$uname' AND password='$pword'"); $row = mysqli_fetch_assoc($result); if(!$row) { echo "Not Found"; echo "<br />"; echo '<a href="index.php?p=5">Start Over</a>'; } else { ?> <P>First Name: <input name="first_name" type="text" value="<?php echo $row["FirstName"] ?>" size="10" /> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <input name="update" type="submit" value="edit info" style="font-size:18px"> </form> </p> <?php } } } ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted November 5, 2018 Share Posted November 5, 2018 Where are you expecting the $_POST fields to come from? The only thing in the form that you submit is a submit button. (first-name input is outside the form) Quote Link to comment Share on other sites More sharing options...
phatgreenbuds Posted November 5, 2018 Author Share Posted November 5, 2018 I am literally slapping myself right now. Thank you. I totally missed that. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted November 5, 2018 Share Posted November 5, 2018 Looking at this revised code of yours see anything wrong here? <?php require('Includes/initialize.php'); $page_title = 'Test'; include_once('Includes/header.php'); // Query Stuff if(isset($_POST['update'])) { // //this is where I expect to see the updated name. Instead its just blank. // echo $_POST['first_name']; } else { if(is_post_request()) { //function to see if its a post from the previous page $uname = $_POST['username']; $pword = $_POST['password']; $result = mysqli_query($db, "SELECT * FROM SubInfo WHERE email='$uname' AND password='$pword'"); $row = mysqli_fetch_assoc($result); if(!$row) { echo "Not Found"; echo "<br />"; echo '<a href="index.php?p=5">Start Over</a>'; } else { $code=<<<heredocs <P>First Name: <input name="first_name" type="text" value="{$row['FirstName']}" size="10" /> <form action="{$_SERVER['PHP_SELF']}" method="post"> <input name="update" type="submit" value="edit info" style="font-size:18px"> </form> </p> heredocs; echo $code; } } } ?> Your form here has only a submit button and no inputs. Quote Link to comment 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.