I have no idea what to do. i keep getting this error when i try to open the page add.php. the page is supposed to create a new user and make a page with username.php for the filename and then it is supposed to enter some stuff into the new page but it is not working. i can get it to create the file and put simple text into it but i can't connect username.php to my database
Parse error: parse error in C:\wamp\www\d_bg,l_txt\users\add.php on line 124
add.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--#########################################################################################################################-->
<title>BHI and Roth's website</title>
<link rel="stylesheet" type="text/css" href="../darkbg.css" />
</head>
<!--#########################################################################################################################-->
<?php
// Connects to your Database
mysql_connect("localhost", "email", "qwe") or die(mysql_error());
mysql_select_db("email") or die(mysql_error());
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] | !$_POST['email'] | !$_POST['fname'] | !$_POST['lname'])
{
die('You did not complete all of the required fields. Click your browsers back button to go back.');
}
// checks if the username is in use
if (!get_magic_quotes_gpc())
{
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$ucheck = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error());
$ucheck2 = mysql_num_rows($ucheck);
//if the username exists it gives an error
if ($ucheck2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use. Click <a href="login.php">here</a> to log in or <a href="add.php">here</a> to try again.');
}
// checks if the email is in use
if (!get_magic_quotes_gpc())
{
$_POST['email'] = addslashes($_POST['email']);
}
$emailcheck = $_POST['email'];
$echeck = mysql_query("SELECT email FROM users WHERE email = '$emailcheck'") or die(mysql_error());
$echeck2 = mysql_num_rows($echeck);
//if the email address exists it gives an error
if ($echeck2 != 0) {
die('Sorry, the email '.$_POST['email'].' is already in use. Click <a href="login.php">here</a> to log in');
}
// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2'])
{
die('Your passwords did not match. ');
}
// here we encrypt the password and add slashes if needed
$_POST['pass'] = md5('a1d3e1j2m1r6v1'.$_POST['pass']);
if (!get_magic_quotes_gpc())
{
$_POST['pass'] = addslashes($_POST['pass']);
$_POST['username'] = addslashes($_POST['username']);
$_POST['email'] = addslashes($_POST['email']);
$_POST['fname'] = addslashes($_POST['fname']);
$_POST['lname'] = addslashes($_POST['lname']);
}
// now we insert it into the database
$insert = "INSERT INTO users (username, password, email, fname, lname)
VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['email']."', '".$_POST['fname']."', '".$_POST['lname']."')";
$add_member = mysql_query($insert);
?>
<!--#########################################################################################################################-->
<!--line 94-->
<?php
$content =
'<html>
<!--#########################################################################################################################-->
<head>
<title>The profile of <?php $_POST[username] ?></title>
</head>
<!--#########################################################################################################################-->
<body>
<h1>Welcome to the Profile page of <?php $_POST[username] ?><br>
<!--#########################################################################################################################-->
<?php
// First connect to database
$host = "localhost";
$dbuser = "email";
$dbpass = "qwe";
$db = "roth";
$con = mysql_connect($host, $dbuser, $dbpass);
if(!$con){
die(mysql_error());
}
$select = mysql_select_db($db, $con);
$data = mysql_query("SELECT * FROM email_contact_list WHERE username == '$username'");
print ("<h3>Contact Information</h3> <hr>");
// This creates a loop which will repeat itself until there are no more rows to select from the database. We getting the field names and storing them in the $row variable. This makes it easier to echo each field.
while($row = mysql_fetch_array($data)){
echo $row['lastname']. " "; echo $row['firstname']. " ";
if (isset($row['wifename']) && $row['wifename'] != NULL && $row['wifename'] != '') {
echo "&"; echo " "; echo $row['wifename']. "<br>";
}
else {
echo "<br>";
}
if (isset($row['address']) && $row['address'] != NULL && $row['address'] != '') {
echo $row['address']. "<br>";
}
if (isset($row['city']) && $row['city'] != NULL && $row['city'] != '') {
echo $row['city']. "<br>";
}
if (isset($row['province']) && $row['province'] != NULL && $row['province'] != '') {
echo $row['province']. "<br>" ;
}
if (isset($row['pc']) && $row['pc'] != NULL && $row['pc'] != '') {
echo $row['pc']. "<br>";
}
if (isset($row['country']) && $row['country'] != NULL && $row['country'] != '') {
echo $row['country']. "<br>";
}
if (isset($row['notes']) && $row['notes'] != NULL && $row['notes'] != '') {
echo $row['notes']. "<br>";
}
if (isset($row['emorpm']) && $row['emorpm'] != NULL && $row['emorpm'] != '') {
echo $row['emorpm']. "<br>";
}
if (isset($row['phone']) && $row['phone'] != NULL && $row['phone'] != '') {
echo $row['phone']. "<br>";
}
if (isset($row['email']) && $row['email'] != NULL && $row['email'] != '') {
echo $row['email']. "<br>";
}
if (isset($row['notes']) && $row['notes'] != NULL && $row['notes'] != '') {
echo $row['notes']. "<br>";
}
echo "<hr>";
}
?>
</body>
</html>
<!--#########################################################################################################################-->
';
$file = "$_POST[username].php";
$open = fopen($file, "w");
fwrite($open, $content);
fclose($open);
?>
<h1>Registered</h1>
<p>Thank you, you have registered - you may now <a href="../login.php">login</a>.</p>
<?php }
else { ?>
<!--#########################################################################################################################-->
<body>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<!--#########################################################################################################################-->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0" style="color:white" align="center">
<tr bgcolor=#276B9A><td>First Name:</td><td> <input type="text" name="fname" maxlength="90" AUTOCOMPLETE="NO"> </td></tr>
<tr bgcolor=#990033><td>Last Name:</td><td> <input type="text" name="lname" maxlength="90" AUTOCOMPLETE="NO"> </td></tr>
<tr bgcolor=#276B9A><td>Email:</td><td> <input type="text" name="email" maxlength="90" AUTOCOMPLETE="NO"> </td></tr>
<tr bgcolor=#990033><td>Username:</td><td> <input type="text" name="username" maxlength="60" AUTOCOMPLETE="NO"> </td></tr>
<tr bgcolor=#276B9A><td>Password:</td><td> <input type="password" name="pass" maxlength="60" AUTOCOMPLETE="NO"> </td></tr>
<tr bgcolor=#990033><td>Confirm Password:</td><td> <input type="password" name="pass2" maxlength="60" AUTOCOMPLETE="NO"> </td></tr>
<tr bgcolor=#276B9A><td colspan=2 align="center"><input type="submit" name="submit" value="Register"></td></tr>
<tr bgcolor=#990033><td colspan=2 align="center">Already got an account? Click <a href="../login.php">here</a> to login</td></tr>
</table>
</form>
<!--#########################################################################################################################-->
</body>
<?php
} ?>
</html>