I’m pretty new to this so please bear with me. I’m trying to make a page where a logged in user can update their row of information in the database. I’ve been sitting here for hours trying to figure this out, so maybe someone can help shed some light on this. Right now I’m even getting a blank white page and can’t figure out why.
<?php
require_once('auth.php');
require_once('config.php');
$errmsg_arr = array();
$errflag = false;
//Connect to mysql server
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$conn) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Create query
$qry="SELECT * FROM members WHERE member_id='" . $_SESSION['SESS_MEMBER_ID'] . "'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
$_SESSION['SESS_EMAIL'] = $member['email'];
session_write_close();
//header("location: index.php");
exit();
}
}else {
die("Query failed");
}
?>
And then I’m trying to display the result of the query in my form I have created as the default value already in the box. From what I can tell it should be something like this?
<input name="fname" type="text" class="textfield" id="fname" value="<?php echo $member['member_id'] ?>"/>
From there I want to pass the new data along so I can write the update sql statement.
Or if you have some sort of resource that can help explain it to me in a simple manner, I’d really appreciate it.
You’re calling
exit()after a successful query. If you proceed to display results, your script will already have terminated.