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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gimpy
Forum Commoner
Posts: 42
Joined: Tue Jun 14, 2005 1:12 am
Location: Fort Worth, TX, US
Contact:

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

Post 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.
Last edited by Gimpy on Wed Jun 15, 2005 12:18 am, edited 2 times in total.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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.
?>
Gimpy
Forum Commoner
Posts: 42
Joined: Tue Jun 14, 2005 1:12 am
Location: Fort Worth, TX, US
Contact:

Post by Gimpy »

so exactly would I place it...sorry :cry: :cry: :roll: 8O :?

strike that, I'm tired at got it.
Post Reply