lundi 22 février 2016

View information by id currently logged in

Help help help anyone :(( I want to edit the information of the current user that is currently logged in, but their infos don't show up from my database. This is what I have so far:

profile.php // this is where their information will show.

<?php
     mysql_connect("localhost", "root", "") or die(mysql_error());
     mysql_select_db("test") or die(mysql_error());

     $id = $_POST['id'];
     $query = mysql_query("SELECT * FROM profile WHERE id = $id"); 
     while($row = mysql_fetch_array($query)) {

    ?>


    <input type="hidden" name="id" value="<?php echo  $row['id'] ?>"/>
    <input type="text" name="firstname" id="firstname" value="<?php echo $row['firstname'] ?>"/>
    <input type="text" name="mi" id="mi" value="<?php echo $row['mi'] ?>" />
    <input type="text" name="lastname" id="lastnamee" value="<?php echo $row['lastname'] ?>" />
    <input type="text" name="gender" id="gender" value="<?php echo $row['gender'] ?>" />
    <input type="text" name="hometown" id="hometown" value="<?php echo $row['hometown'] ?>" />
    <input type="text" name="contactno" id="contactno" value="<?php echo $row['contactno'] ?>" />

But when I run this, I get these errors:

Notice: Undefined index: id

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given

Aucun commentaire:

Enregistrer un commentaire