Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP/MySQL Edit Account Information
    primarykey
    data
    text
    <p>i have 2 files edit.php and update.php edit.php first</p> <pre><code>&lt;?php session_start(); $_SESSION['id'] = '9'; $id = $_SESSION["id"]; $username = $_POST["username"]; $fname = $_POST["fname"]; $password = $_POST["password"]; $email = $_POST["email"]; mysql_connect('mysql13.000webhost.com', 'a2670376_Users', 'PASSWORD') or die(mysql_error()); echo "MySQL Connection Established! &lt;br&gt;"; mysql_select_db("a2670376_Pass") or die(mysql_error()); echo "Database Found!&lt;br&gt;"; $query = "UPDATE members SET username = '$username', fname = '$fname', password = '$password' WHERE id = '$id'"; $res = mysql_query($query); if ($res) echo "&lt;p&gt;Record Updated $rows[id]&lt;p&gt;"; else echo "Problem updating record MySQL Error: " . mysql_error(); ?&gt; &lt;form action="update.php" method="post"&gt; &lt;input type="hidden" name="id" value="&lt;?=$id;?&gt;"/&gt; ScreenName:&lt;br&gt; &lt;input type='text' name='username' id='username' maxlength='25' style='width:247px' name="username" value="&lt;?=$username;?&gt;"/&gt;&lt;br&gt; FullName:&lt;br&gt; &lt;input type='text' name='fname' id='fname' maxlength='20' style='width:248px' name="fname" value="&lt;?=$fname;?&gt;"/&gt;&lt;br&gt; Email:&lt;br&gt; &lt;input type='text' name='email' id='email' maxlength='50' style='width:250px' name="email" value="&lt;?=$email;?&gt;"/&gt;&lt;br&gt; Password:&lt;br&gt; &lt;input type='text' name='password' id='password' maxlength='25' style='width:251px' value="&lt;?=$password;?&gt;"/&gt;&lt;br&gt; &lt;input type="Submit"&gt; &lt;/form&gt; </code></pre> <p>now update.php</p> <pre><code>&lt;?php session_start(); mysql_connect('mysql13.000webhost.com', 'a2670376_Users', 'PASSWORD') or die(mysql_error()); mysql_select_db("a2670376_Pass") or die(mysql_error()); $id = (int)$_SESSION["id"] = $_SESSION['id']; $username = mysql_real_escape_string($_POST["username"]); $fname = mysql_real_escape_string($_POST["fname"]); $email = mysql_real_escape_string($_POST["email"]); $password = mysql_real_escape_string($_POST["password"]); $query="UPDATE members SET username = '$username', fname = '$fname', email = '$email', password = '$password' WHERE id = '$id'"; mysql_query($query)or die(mysql_error()); if(mysql_affected_rows()&gt;=1){ echo "&lt;p&gt;($id) Record Updated&lt;p&gt;"; }else{ echo "&lt;p&gt;($id) Not Updated $_SESSION[username]&lt;p&gt;"; } ?&gt; </code></pre> <p>heres my problem in edit.php the line that says <code>$_SESSION['id'] = '9';</code> now if that line does not say '9' it will not update the user that has the id 9 thats the only user i have sofar the id in the database is 9 if that line is not there it will not work at all it wont update any ones information how do i make this pull the id from the current user logged in</p> <p>heres my login code </p> <pre><code>&lt;?php session_start(); // Check if he wants to login: if (!empty($_POST[username])) { require_once("connect.php"); // Check if he has the right info. $query = mysql_query("SELECT * FROM members WHERE username = '$_POST[username]' AND password = '$_POST[password]'") or die ("&lt;center&gt;Error - Couldn't login user!!"); $row = mysql_fetch_array($query) or die ("&lt;center&gt;Error - Couldn't login user!!"); if (!empty($row[username])) // he got it. { $_SESSION[username] = $row[username]; echo "&lt;center&gt;Welcome $_POST[username]! You've been successfully logged in. &lt;br&gt;&lt;h2 style='color: Yellow;'&gt;REDIRECTING.....&lt;/H2&gt;&lt;br&gt;&lt;img src='http://i1261.photobucket.com/albums/ii586/jacob1899/ajax-loader-1.gif'&gt;&lt;/center&gt; &lt;meta http-equiv='REFRESH' content='1;url=/index.htm'&gt;"; exit(); } else // bad info. { echo "&lt;center&gt;Error - Couldn't login user!!"; exit(); } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload