please help im a complete noob

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
chrismarsden
Forum Newbie
Posts: 14
Joined: Wed Jul 09, 2008 11:37 am

please help im a complete noob

Post by chrismarsden »

there seems to be someting wrong (probably my settings)
i have a problem, i should note this is code i have taken from a pre written script.

full code to register.php:

Code: Select all

 
<?php
require_once('db.php');
include('functions.php');
include('settings.php');
if (array_key_exists('_submit_check', $_POST))
{
if ( $_POST['username'] != '' && $_POST['password'] != '' && $_POST['password'] == $_POST['password_confirmed'] && $_POST['email'] != '' && valid_email ( $_POST['email'] ) == TRUE )
{
if ( ! checkUnique('Username', $_POST['username']) )
{
$error = 'Username already taken. Please try again!';
}
elseif ( ! checkUnique('Email', $_POST['email']) )
{
$error = 'The email you used is associated with another user. Please try again or use the "forgot password" feature!';
}
else { 
$query = mysql_query("INSERT INTO users (`Username` , `Password`, `Email`, `Random_key`) VALUES ('".mysql_real_escape_string($_POST['username'])."', '".mysql_real_escape_string(md5($_POST['password']))."', '".mysql_real_escape_string($_POST['email'])."', '".random_string('alnum', 32)."')") or die(mysql_error());
 
$getUser = mysql_query("SELECT ID, Username, Email, Random_key FROM users WHERE Username = '".mysql_real_escape_string($_POST['username'])."'") or die(mysql_error());
 
if(mysql_num_rows($getUser)==1)
{ 
$row = mysql_fetch_assoc($getUser);
$headers = 'From: ' . $site_email . "\r\n" .
'Reply-To: ' . $site_email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = "Activation email from " . $domain_name;
$message = "Dear ".$row['Username'].", this is your activation link to join our website. In order to confirm your membership please click on the following link: ".$url."confirm.php?ID=".$row['ID']."&key=".$row['Random_key']." Thank you for joining";
if ( mail($row['Email'], $subject, $message, $headers ) )
{
$msg = 'Account created. Please login to the email you provided during registration and confirm your membership.';
}
else {
$error = 'I created the account but failed sending the validation email out.';
}
}
else {
$error = 'You just made possible the old guy (the impossible). Please inform my boss in order to give you the price for this.';
}
} 
}
else { 
$error = 'There was an error in your data. Please make sure you filled in all the required data, you provided a valid email address and that the password fields match one another'; 
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>roScripts.com - PHP Login System Witn Admin Features</title>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<!--
____ __
/\ _`\ __ /\ \__
_ __ ___\ \,\L\_\ ___ _ __ /\_\ _____\ \ ,_\ ____
/\`'__\/ __`\/_\__ \ /'___\/\`'__\/\ \/\ '__`\ \ \/ /',__\
\ \ \//\ \L\ \/\ \L\ \/\ \__/\ \ \/ \ \ \ \ \L\ \ \ \_/\__, `\
\ \_\ \____/\ `\____\ \____\ \_\ \ \_\ \ ,__/\ \__\/\____/
\/_/ \/___/ \/_____/\/____/ \/_/ \/_/\ \ \/ \/__/\/___/
\ \_\
\/_/
Making your world easy
-->
</head>
<body>
<div id="log">
<?php if ( isset ( $error ) ) { echo ' <p class="error">' . $error . '</p>' . "\n"; } ?>
<?php if ( isset ( $msg ) ) { echo ' <p class="msg">' . $msg . '</p>' . "\n"; } else {//if we have a mesage we don't need this form again.?>
</div>
<div id="container" style="text-align:center">
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input type="hidden" name="_submit_check" value="1"/> 
 
<table align="center" width="99%">
 
<tr>
<td><div align="left">Username</div></td>
</tr>
<tr>
<td><div align="left"><input class="input" type="text" id="username" name="username" size="32" value="<?php if(isset($_POST['username'])){echo $_POST['username'];}?>" /></div></td>
</tr>
<tr>
 
<td><div align="left">Password</div></td>
</tr>
<tr> 
<td><div align="left"><input class="input" type="password" id="password" name="password" size="32" value="" /></div></td> 
</tr>
<tr>
 
<td><div align="left">Re-Password</div></td>
</tr>
<tr> 
<td><div align="left"><input class="input" type="password" id="password_confirmed" name="password_confirmed" size="32" value="" /></div></td> 
</tr>
<tr>
<td><div align="left">Email</div></td>
</tr>
<tr> 
<td><div align="left"><input class="input" type="text" id="email" name="email" size="32" value="<?php if(isset($_POST['email'])){echo $_POST['email'];}?>" /></div></td>
 
</tr>
 
<tr>
<td>
<input type="image" name="register" value="register" class="submit-btn" src="http://www.roscripts.com/forum/images/btn.gif" alt="submit" title="submit" />
<br class="clear" />
</td>
</tr>
 
</table>
</form>
</div>
<? } ?>
</body
</html>
 
it gives output:

Parse error: syntax error, unexpected $end in C:\wamp\www\register.php on line 123

only thing is there is no line 123...
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: please help im a complete noob

Post by Reviresco »

That error means that you are missing a closing bracket: } somewhere.

The script's too long for me to sift through it for you to find it though...
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: please help im a complete noob

Post by califdon »

Try putting a closing angle bracket on the next-to-last line:

Code: Select all

</body[color=#FF0000][b]>[/b][/color]
</html>
chrismarsden
Forum Newbie
Posts: 14
Joined: Wed Jul 09, 2008 11:37 am

Re: please help im a complete noob

Post by chrismarsden »

hey guys thanks, i fixed the problem, i realised it was due to using short <? with long <?php tags in the same file, i now have another problem, when i register a dummy account it wont send an email (im using apache on my laptop) is it possible to set up an email or get round this problem?

also whhen i manualy configure the account i just set up it wont login, takes me to a 403 error page.

any help for the noob? (i will get better with time lol)
Post Reply