Jump to content

Php Profile Help


Alex2k15

Recommended Posts

Yeah idk what's wrong and i want some help.
 
Let's start with edit.php
 
<?php
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
	header("Location: index.php");
}
$res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home - <?php echo $userRow['username']; ?></title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<div id="header">
	<div id="left">
    <label>Chillz</label>
    </div>
    <div id="right">
    	<div id="content">
        	Welcome,  <?php echo $userRow['username']; ?> <a href="logout.php?logout">Sign Out</a>
        </div>
    </div>
</div>
<div id="body">
   <b>Edit your Profile</b>  
  <br><br>
   Please enter your details below to update your profile.  
  <br><br>
    <form method="post" action="editprofile.php" name="editform" id="editform"> 
    <table width=700px border=0 cellspacing=10><tr><td valign=top><table border=0>
<b>Required Information:</b><br><br>
<tr><td>  
        <b>Username:</b>
</td><td>
        <?php echo $username; ?>
</td></tr><tr><td>  
        <b>Email Address:</b>
</td><td>
        <input type="text" name="email" id="email" value="<?php echo $email; ?>">
</td></tr></table></td><td valign=top>
<table border=0>
<b>Optional Information:</b><br><br>
<tr><td>
     <b>Location:</b>
</td><td>
     <input type="text" name="location" id="location" value="<?php echo $location; ?>">
</td></tr><tr><td>
     <b>Your Website:</b>
</td><td>
     <input type="text" name="website" id="website" value="<?php echo $website; ?>">
</tr></td><tr><td valign=top>
     <b>Short About:</b>
</td><td>
     <textarea name="about" id="about" rows="10" cols="20"><?php echo $about; ?></textarea>
</td></tr></td>
</table> </td></tr> </table>
        <input type="submit" name="register" id="register" value="Update" class=btn />  
    </form>  
  </div>
<?php
$editquery = mysql_query("Update users (email, location, website, about) VALUES('".$email."', '".$location."', '".$website."', '".$about."')");

if($editquery ==)  
        {  
            echo "<b>Success!</b>";  
            echo "Your profile was successfully updated. Please click<a href=\"viewprofile.php\"> here </a>to view.";  
        }  
        else  
        {  
            echo "<b>Error</b>";  
            echo "<p>Sorry, your profile update failed. Please go back and try again.</p>";  
        }  

?>
</div>
</body>
</html>

I can't upload an image but here is the urls: 

 

http://i.imgur.com/ZkHMM4a.jpg

http://i.imgur.com/HsAhfiM.jpg

 

I want to remove the error part. Plus i was hoping someone can help me work on the profile part

Link to comment
Share on other sites

Yes, that is the correct syntax, but in your example, you're missing the closing quotation, so you have to be careful of that.

 

This is how it looks:

<?php
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
	header("Location: index.php");
}
$res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home - <?php echo $userRow['username']; ?></title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<div id="header">
	<div id="left">
    <label>Chillz</label>
    </div>
    <div id="right">
    	<div id="content">
        	Welcome,  <?php echo $userRow['username']; ?> <a href="logout.php?logout">Sign Out</a>
        </div>
    </div>
</div>
<div id="body">
   <b>Edit your Profile</b>  
  <br><br>
   Please enter your details below to update your profile.  
  <br><br>
    <form method="post" action="editprofile.php" name="editform" id="editform"> 
    <table width=700px border=0 cellspacing=10><tr><td valign=top><table border=0>
<b>Required Information:</b><br><br>
<tr><td>  
        <b>Username:</b>
</td><td>
        <?php echo $username; ?>
</td></tr><tr><td>  
        <b>Email Address:</b>
</td><td>
        <input type="text" name="email" id="email" value="<?php echo $email; ?>">
</td></tr></table></td><td valign=top>
<table border=0>
<b>Optional Information:</b><br><br>
<tr><td>
     <b>Location:</b>
</td><td>
     <input type="text" name="location" id="location" value="<?php echo $location; ?>">
</td></tr><tr><td>
     <b>Your Website:</b>
</td><td>
     <input type="text" name="website" id="website" value="<?php echo $website; ?>">
</tr></td><tr><td valign=top>
     <b>Short About:</b>
</td><td>
     <textarea name="about" id="about" rows="10" cols="20"><?php echo $about; ?></textarea>
</td></tr></td>
</table> </td></tr> </table>
        <input type="submit" name="register" id="register" value="Update" class=btn />  
    </form>  
  
<?php
$editquery = mysql_query("UPDATE users SET email=$email, password=$password, location=$location, picture=$picture, website=$website, about=$about WHERE user_id=._$SESSION['user']); 

if($editquery)  
        {  
            echo "<b>Success!</b>";  
            echo "Your profile was successfully updated. Please click<a href=\"profile.php\"> here </a>to view.";  
        }  
        else  
        {  
            echo "<b>Error</b>";  
            echo "<p>Sorry, your profile update failed. Please go back and try again.</p>";  
        }  

?>
</div>
</body>
</html>

i feel like i did the WHERE part wrong.

 

Plus i get this error.

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/u890091543/public_html/login/edit.php on line 68

Edited by Alex2k15
Link to comment
Share on other sites

Just like I said, you are missing the ending quotation at the end of the where clause. It should look something like this:

<?php

$editquery = mysql_query("UPDATE users SET email=$email, password=$password, location=$location, picture=$picture, website=$website, about=$about WHERE user_id='" ._$SESSION['user'] . "'");

?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.