Page 1 of 1

[SOLVED] Form Registration error?(But I still need help)

Posted: Tue Jun 14, 2005 11:51 pm
by Gimpy

Code: Select all

<?php
$con=mysql_connect("localhost", "user", "userpass") or die("Could not connect to localhost."); mysql_select_db("gimpy", $con) or die("Could not find db.");
$username=$_POST['username']; $password = md5($_POST['password']); $email=$_POST['email']; $aim=$_POST['aim']; $yim=$_POST['yim']; $msn=$_POST['msn'];
mysql_query ("INSERT INTO users (username, password, email, aim, yim, msn) VALUES ('$username', '$password', '$email', '$aim', '$yim', '$msn')");
mysql_close($con);

// Redirects the browser quickly (don't forget the URL=)
header("Location:index.php");
?>
And this is the result I get...

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at E:\Web\register.php:9) in E:\Web\register.php on line 16
line 8 is line 16 in my error if you didnt already know :cry:

I am a newbie to this stuff and maybe I'm just overlooking something. When they register I want to page to refresh to the index page so they can log in and etc..

Oh and if I should fix anything else please let me know. I am looking into a session based system (if you know of any good tuts, please help?? ) to because eventually I want to create a Admin CP that will allow the user to add/rem links and body text and other stuff but I'd figured that was way to advanced for now so I'll hold off for now.

Posted: Tue Jun 14, 2005 11:55 pm
by anjanesh
There should be no output to the browser before any header call - like HTML tag or echo or print commands.

Wont work :

Code: Select all

<html>
header("Location:index.php");
</html>

Code: Select all

<?php
// Only PHP code with no echo or print.
header("Location:index.php");
// HTML stuff or PHP that outputs HTML stuff.
?>

Posted: Wed Jun 15, 2005 12:14 am
by Gimpy
so exactly would I place it...sorry :cry: :cry: :roll: 8O :?

strike that, I'm tired at got it.