View Full Version : Help in PHP


LuNacHicK
05-09-2003, 03:08 PM
Hi! I jez want to know what this means.... I'm building a shopping cart with a registration form in it.... its working though... but what's up with those warnings?!?!.....


Warning: Cannot send session cookie - headers already sent by (output started at /home/virtual/site68/fst/var/www/html/register.php:2) in /home/virtual/site68/fst/var/www/html/register.php on line 4

Warning: Cannot send session cache limiter - headers already sent (output started at /home/virtual/site68/fst/var/www/html/register.php:2) in /home/virtual/site68/fst/var/www/html/register.php on line 4
Ok!
Warning: Cannot add header information - headers already sent by (output started at /home/virtual/site68/fst/var/www/html/register.php:2) in /home/virtual/site68/fst/var/www/html/register.php on line 59
Thanks! You have been registered.

Jasper
05-09-2003, 04:05 PM
It says that you have a few errors in your register.php file. Maybe if you post the code of the register.php, the people that know PHP on these forums could help you out! (I only know a little).

LuNacHicK
05-09-2003, 10:52 PM
Here's my register.php code....


<?php
session_start();


$hostname_mysql = "MyLocalhost";
$database_mysql = "MyDatabase";
$username_mysql = "blah";
$password_mysql = "blah";
$mysql = mysql_pconnect("$hostname_mysql", "$username_mysql", "$password_mysql") or die(mysql_error());
if (!$mysql)
{
echo "Couldn't make a connection!";
exit;
}

$db = mysql_select_db("$database_mysql",$mysql);
if(!$db)
{
echo "The database disappeared!";
mysql_close($mysql);
exit;
}
echo"Ok!";
if (empty($memberpass)|| empty($memberpass2)||empty($username)||empty($emai l))
{
die("Error! All fields are required. Please try again!");
}

if ($memberpass != $memberpass2)
{
die ("Error! Passwords do not match. Please try again!");
}

if(!eregi('^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3})?)$',$email))
{
die("Error! $email does not look like valid email address.");
}

if (strlen($username)<2 || strlen($usrname)>50)
{
die ("Error! $username must be between 1 to 50 characters");
}

if (strlen($memberpass)<6||strlen($memberpass)>10)
{
die("Error! Password must be between 6 to 10 characters.");
}

$enc_pass = md5($memberpass);
$query = "INSERT into members (member_id,username,email,memberpass) VALUES ('','$username','$email','$enc_pass')";
$result= mysql_query($query) or die
("Could not execute query: $query." .mysql_error());

if ($result)
{
session_register($username);
setcookie("siteuser",$username,time()+604800);
echo "Thanks! You have been registered.";

}
?>

younghistorians
05-10-2003, 12:54 AM
Ok, this could be a number of problems.
1. It could have to do with CHMOdding. Did you set the correct permissions in your FTP?
2. I am not liking the setcookie(blah blah) code....If the above does not fix the problem, I will revise your script, so it set's cookies in a slightly different way.


Have fun!

LuNacHicK
05-10-2003, 02:27 AM
CHMOD? I'm sorry! I'm new in PHP... and I find it very confusing! Can you explain it a lil further? Thanks!

Cherchezlafemme
05-10-2003, 02:30 AM
Do you have FTP ? then, you use that to CHMOD it is usually required! Go on Starlet's site click enter then tutorials you find an FTP helps there!


Yet, if you use antything outside of windows then i have no clue what so ever!

LuNacHicK
05-10-2003, 02:54 AM
Yup! I use FTP...
Like how do I CHMOD it?!...

lefty
05-10-2003, 02:58 AM
Each FTP client is different, but I know all I have to do (I use smartFTP) is right click on the file and go to properties/CHMOD. Then you'd just put in the correct permissions. Don't know what program you use to FTP, but it can't be too different!

LuNacHicK
05-10-2003, 06:42 AM
I use cuteFTP... What should I put it in there?

younghistorians
05-10-2003, 11:05 AM
Hello.
I believe for your type of script, you need to CHMOD it to the numbers 7 6 7.