Page 1 of 1
PHP Help Needed Immediately
Posted: Fri Apr 16, 2004 3:34 pm
by prithvim
hi guys,
i need some help with thi script that i just wrote in PHP. actually it is my first script but i was pretty confident that it would work well.
but only the register.php and login.php pages are loading.
in everything else there is an error message saying error while parsing on line 3 for all scripts.
the scripts are for a blog. they are located at :
http://www.prithvidesign.com/blogtest/
and all the files are in the zip file in the same folder.
please help me out.
Posted: Fri Apr 16, 2004 3:41 pm
by qads
you may wanna post your code, i.e, what is on line 3?
Posted: Fri Apr 16, 2004 3:43 pm
by feyd
I only looked at signup.php and login.php, but in signup, you have
it should be
Posted: Fri Apr 16, 2004 3:53 pm
by steve2004
Had quick look at some of scripts
need to use
session_start();
session_register('username');
error code
Posted: Fri Apr 16, 2004 4:03 pm
by prithvim
Code: Select all
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/prithvim/public_html/blogtest/signup.php on line 14
this is the latest error code i am getting after making a few changes
Posted: Fri Apr 16, 2004 4:11 pm
by Steveo31
steve2004 wrote:Had quick look at some of scripts
need to use
session_start();
session_register('username');
PHP.net says _register is deprecated.
Posted: Fri Apr 16, 2004 4:17 pm
by steve2004
fair comment steveo
php version?
Posted: Fri Apr 16, 2004 4:24 pm
by prithvim
mine is 4.3.4 i guess
Posted: Fri Apr 16, 2004 4:58 pm
by steve2004
debug
try echo variables when in functions see what values they have, helps track down bugs also try
global vars
hope this helps!
Posted: Fri Apr 16, 2004 5:14 pm
by prithvim
these are the two scripts that i am using:
Code: Select all
<html>
<head>
<title>New User Registration</title>
</head>
<body>
<div>
<form action="signup.php" method="post">
<p>
Desired UserID: <input type="text" name="userid" length="8" size="8"><br>
Password: <input type="password" name="password" length="8" size="8"><br>
Full Name: <input type="text" name="name" length="25" size="25"><br>
Email: <input type="text" name="email" length="50" size="50"><br>
</p>
<input type="reset" value="Reset">
<input type="submit" value="Submit">
<p>
<b>Note: All fields are mandatory.</b>
</p>
</form>
</div>
</body>
</html>
and
Code: Select all
<?php
if ( !empty($_POSTї'userid']) && !empty($_POSTї'password']) && !empty($_POSTї'name']) && !empty($_POSTї'email']) )
{
check_userid();
}
else
{
die("<b>Please go back and fill in all the fields.</b>");
}
function check_userid()
{
if(file_exists("$_POSTїuserid].txt"))
{
die("The UserID <b>$_POSTїuserid]</b> already exists.<br/>Please choose another UserID.");
}
else
{
create_file();
}
}
function create_file()
{
touch("$_POSTїuserid].txt");
if($fp=fopen("$_POSTїuserid].txt","w"))
{
create_userid();
}
else
{
die("There was an error processing your request.<br/>Please try again later.");
}
}
function create_userid()
{
if(fwrite($fp,"$_POSTїuserid]\n$_POSTїpassword]\n$_POSTїname]\n$_POSTїemail]\n"))
{
fclose($fp);
die("UserID <b>$_POSTїuserid]</b> successfully created.");
}
else
{
die("There was an error processing your request.<br/>Please try again later.");
}
}
?>
and this is the error message:
Code: Select all
Warning: fwrite(): supplied argument is not a valid stream resource in /home/prithvim/public_html/blogtest/signup.php on line 38
There was an error processing your request.
Please try again later.
Posted: Fri Apr 16, 2004 5:22 pm
by feyd
$fp isn't globally available. Should probably return it from create_file() and pass it to create_userid()
Posted: Fri Apr 16, 2004 5:41 pm
by prithvim
how do i do that?
Posted: Fri Apr 16, 2004 5:49 pm
by feyd
change
in create_file() to
then change
to
Posted: Fri Apr 16, 2004 6:25 pm
by prithvim
hey thanks a lot guys.
now the first part of the script is working.
guess i'll be able to manage the rest of them myself.
anyway...u will seeing more of me here.