Jump to content

MySql Update PHP HELP PLZ!!


xTract

Recommended Posts

Im trying to make a edit profile page for my login system and everytime i submit it erases all the current data and doesn't update. Please help me!!

 

<?php
session_start();
include 'config.php';
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Members Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style1.css" rel="stylesheet" type="text/css">
</head>

<body>

<div id="wrapper">

<div id="head">The member page

<?php include "nav.php"; ?>

</div><br>
<div id="container">
<? include 'menus.php'; ?>
</div>
<div id="spacer"> </div>
<div id="memmain">

<?

if($_SESSION['s_logged_n'] == 'true'){
include 'process.php';


    $username = trim(addslashes($_SESSION['s_username']));



//select the table
$result = mysql_query("SELECT * FROM Users WHERE Username = '$username' ");

//grab all the content
while($r=mysql_fetch_array($result))
{   
   //the format is $variable = $r["nameofmysqlcolumn"];
   //modify these to match your mysql table columns

   $avatar=$r["Avatar"];
   $name=$r["Name"];
   $location=$r["Location"];
   $email=$r["Email"];
   $rank=$r["Rank"];
   $website=$r["Website"];
   $gamertag=$r["Gamertag"];
   $msn=$r["Msn"];
   $aol=$r["Aol"];
   $yahoo=$r["Yahoo"];
   $signature=$r["Signature"];
   $interests=$r["Interests"];
   $occupation=$r["Occupation"];
   $bio=$r["Bio"];
    $self = $_SERVER['PHP_SELF'];

$ip = $_SERVER['REMOTE_ADDR'];

  
   //display the row

}


$todo=$_POST['todo'];
$namenew=$_POST['Name'];
$emailnew=$_POST['Email'];
$locationnew=$_POST['Location'];
$msnnew=$_POST['Msn'];
$aolnew=$_POST['Aol'];
$yahoonew=$_POST['Yahoo'];
$bionew=$_POST['Bio'];
$interestsnew=$_POST['Interests'];
$occupationnew=$_POST['Occupation'];
$avatarnew=$_POST['Avatar'];
$signaturenew=$_POST['Signature'];
$gamertagnew=$_POST['Gamertag'];

// check the login details of the user and stop execution if not logged in require "check.php";

if(isset($todo) and $todo=="update-profile"){


// set the flags for validation and messages
$status = "OK";
$msg="";



// you can add email validation here if required.
// The code for email validation is available at www.plus2net.com


if($status<>"OK"){ // if validation failed
echo "<font face='Verdana' size='2' color=red>$msg</font>
<br><input type='button' value='Retry' onClick='history.go(-1)'>";

}else{ // if all validations are passed.

if(mysql_query("update Users set email='$emailnew',name='$namenew',email='$emailnew', location='$locationnew', msn='$msnnew', aol='$aolnew', yahoo='$yahoonew', bio='$bionew', interests='$interestsnew', occupation='$occupationnew', avatar='$avatarnew', signature='$signaturenew', gamertag='$gamertagnew' where username='$username'")){
echo "<font face='Verdana' size='2' color=green>You have successfully updated your profile<br></font>";
}else{echo "<font face='Verdana' size='2' color=red>There is some problem in updating your profile. Please contact site
admin<br></font>";}
}}





?>

        <form action="#" method='post'>
<input type=hidden name=todo value=update-profile>


      <table width="100%"  border="0" cellpadding="0" cellspacing="0">
        <tr class="secondRow">
          <td colspan="2"><div align="center"><span style="font-size:22px;color:#3366ff;"><b><u><? echo "$username"; ?></b></u></span></div> </td>
        </tr>

        <tr class="firstRow">
          <td width="30%">Full Name </td>
          <td width="70%"><input name="name" type="text" class="textBox" value="<? echo "$name"; ?>"></td>
        </tr>
        <tr class="secondRow">
          <td>E-Mail</td>
          <td><input name="email" type="text" class="textBox" value="<? echo "$email"; ?>"></td>
        </tr>
        <tr class="firstRow">
          <td width="30%">Location </td>
          <td width="70%"><input name="location" type="text" class="textBox" value="<? echo "$location"; ?>"></td>
        </tr>
        <tr class="secondRow">
          <td>Group </td>
          <td><input name="rank" type="text" class="textBox" value="<? echo "$rank"; ?>"> Cannot Edit..</td>
        </tr>
        <tr class="firstRow">
          <td width="30%">MSN </td>
          <td width="70%"><input name="msn" type="text" class="textBox" value="<? echo "$msn"; ?>"></td>
        </tr>
        <tr class="secondRow">
          <td>AOL</td>
          <td><input name="aol" type="text" class="textBox" value="<? echo "$aol"; ?>"></td>
        </tr>
        <tr class="firstRow">
          <td width="30%">Yahoo </td>
          <td width="70%"><input name="yahoo" type="text" class="textBox" value="<? echo "$yahoo"; ?>"></td>
        </tr>
        <tr class="secondRow">
          <td valign="top">Biography</td>
          <td><textarea id="bio" name ="bio" rows="15" cols="30" ><? echo "$bio"; ?></textarea></td>
        </tr>
        <tr class="firstRow">
          <td width="30%">Interests </td>
          <td width="70%"><textarea id="interests" name ="interests" rows="2" cols="22" value=""><? echo "$interests"; ?></textarea></td>
        </tr>
        <tr class="secondRow">
          <td>Occupation</td>
          <td><input name="occupation" type="text" class="textBox" value="<? echo "$occupation"; ?>"></td>
        </tr>
        <tr class="firstRow">
          <td width="30%">Avatar </td>
          <td width="70%"><input name="avatar" type="text" class="textBox" value="<? echo "$avatar"; ?>"></td>
        </tr>
        <tr class="secondRow">
          <td>Signature</td>
          <td><textarea id="signature" name ="signature" rows="4" cols="22" value=""><? echo "$signature"; ?></textarea></td>
        </tr>
        <tr class="firstRow">
          <td width="30%">Gamer Tag </td>
          <td width="70%"><input name="gamertag" type="text" class="textBox" value="<? echo "$gamertag"; ?>"></td>
        </tr>

        <tr class="secondRow">
          <td width="30%">Edit Profile </td>
          <td width="70%"><input type="submit" value="Edit Profile" name="Submit"></td>
        </tr>


</table>

</FORm>


<?




}
else {
echo "Please login";
}
?>

</div>

</body>
</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/101003-mysql-update-php-help-plz/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.