I’ve just made a user profile page for my site, i’m trying to make it so you can edit your details e.g. email, location..ect.. but i’m having a little trouble with the edit section. It seems to edit the email like it should, but it doesn’t want to take it back to the profile page…. I’m sure this is something silly, but I can’t work it out. ?
here’s my script.
[code=php]
<?php session_start();?>
<?php
$username = $_SESSION[‘username’];
$conn = mysql_connect(“localhost”,”username”,”password”)
or die(“Could not connect”);
$rs = mysql_select_db(“unicyclepics”,$conn)
or die(“Could not select database”);
$sql1 = “SELECT * FROM users WHERE user_name = ‘$username'”;
$result = mysql_query($sql1) or die(mysql_error());
$r = mysql_fetch_assoc($result);
$email = $r[’email’];
?>
<?php
if( (!$_POST[’email2′]) )
{
$form =”<p>Email: $email</p>”;
$form.=”<form action=”$PHP_SELF””;
$form.=” method=”post”>Email:<br /> “;
$form.=”<input type=”text” name=”email2″”;
$form.=” value=”$email2″><br /><br />”;
$form.=”<input type=”submit” value=”Edit”>”;
$form.=”</form>”;
echo($form);
}
else
{ $conn = mysql_connect(“localhost”,”username”,”password”)
or die(“Could not connect”);
$rs = mysql_select_db(“unicyclepics”,$conn)
or die(“Could not select database”);
$sql = “UPDATE users SET email = ‘$email2’ WHERE user_name = ‘$username'”;
$result = mysql_query($sql,$conn)
or die(mysql_error());
header(‘Location: http://’.$_SERVER[‘HTTP_HOST’].’/profile.php’);
}
?>
The error looks like this.
[code=html]Warning: Cannot modify header information – headers already sent by (output started at /home/fhlinux184/u/unicyclepics.co.uk/user/htdocs/edit.email.php:9) in /home/fhlinux184/u/unicyclepics.co.uk/user/htdocs/edit.email.php on line 84
And line 84 is the “header(‘Location:…” line.
If anyone can tell me where i’ve gone rong, i’ll be very happy. ?