Hello all i'm trying to write my first script. I want a form that writes to a file i have a parse error at $srtingtowrite. Is someone here willing to look at the script an tell me whats wrong? Here it is. Thanx in advance
<?php
if ($HTTP_POST_VARS['submit']) {
$required_fields = explode(",", $HTTP_POST_VARS['required']);
$error = 0;
foreach($required_fields as $fieldname) {
if ($HTTP_POST_VARS[$fieldname] == "") {
$error++;
}
}
if ($error == 0) {
if (strstr($HTTP_POST_VARS['email'], "@") and strstr($HTTP_POST_VARS['email'], ".")) {
print "<html><body>Thank you for registering $HTTP_POST_VARS[name]!</body></html>";
exit;
} else {
$errormessage = "<b>The email address you entered does not appear to be valid<br></b>";
}
} else {
$errormessage = "<b>You have left some required fields in the form blank! Please fill in the form completely.";
}
}
?>
<?php
if ($HTTP_POST_VARS['submit']) {
print "the form has been submitted";
}
?>
<p><br>
<br>
<?=$errormessage?>
</p>
<table border="2" width="611" align="center" bordercolor="#333333" height="1060">
<tr bgcolor="#663366">
<td> <font color="#FFFFFF"
size="2" face="Arial"><strong> Registeration </strong></font></td>
</tr>
<tr bgcolor="#999999" bordercolor="#333333">
<td valign="top" height="1075">
<div align="center">
<table border="0">
<tr bgcolor="#999999">
<td> <font face="Verdana">Thank you for signing up. Now we need to
set up your account</font>.<font color="#999999">....... </font><font color="#000080" size="2" face="Verdana">
Please fill out the form below:</font><font color="#000080" size="2" face="Arial">
</font></td>
</tr>
<tr bgcolor="#999999">
<td>
<blockquote>
<form method="post" action="
<?=$HTTP_SERVER_VARS['PHP_SELF']?>
" name="php register">
<p>
<input type="hidden" name="action" value="register">
</p>
<table border="0" align="center" width="519" height="869">
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Login
Name: </font></td>
<td>
<input type="text" size="15" name="login" value="
<?=$HTTP_POST_VARS['loginname']?>
">
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Password:
</font></td>
<td>
<input type="password" size="15" name="password1">
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Password
again: </font></td>
<td>
<input type="password" size="15" name="password2">
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Name:
</font></td>
<td>
<input type="text" size="15" name="name2" value="
<?=$HTTP_POST_VARS['name']?>
">
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> E-mail:
</font></td>
<td>
<input type="text" size="15" name="email2" value="
<?=$HTTP_POST_VARS['email']?>
">
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Age:
</font></td>
<td>
<input type="text" size="2" name="age">
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2">Sex:</font></td>
<td>
<select name="sex" size="1">
<option value=" ">
<option value="male"> Male </option>
<option value="female"> Female </option>
</select>
</td>
</tr>
<tr>
<td height="22"><font color="#FFFFFF" face="Verdana" size="2">Marital
Status:</font></td>
<td height="22">
<select name="status" size="1">
<option value=" ">
<option value="single"> Single </option>
<option value="married"> Married </option>
</select>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Occupation:
</font></td>
<td>
<input type="text" size="15" name="occupation" value="
<?=$HTTP_POST_VARS['occupation']?>
">
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2">ed
id</font></td>
<td>
<input type="text" name="edid" value="
<?=$HTTP_POST_VARS['edid']?>
">
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Favorite
Quote:</font></td>
<td>
<input type="text" name="quote" rows="3" cols="30"
wrap="soft">
<?=$HTTP_POST_VARS['favoritequote']?>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Hobbies:</font></td>
<td>
<input type="text" name ="hobbies" rows="3" cols="30"
wrap="soft">
<?=$HTTP_POST_VARS['hobbies']?>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> News:</font></td>
<td>
<input type="text" name="news" rows="3" cols="30"
wrap="soft">
<?=$HTTP_POST_VARS['news']?>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Homepage:
</font></td>
<td>
<input type="text" size="15" name="homepage" value="
<?=$HTTP_POST_VARS['homepage']?>
">
</td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Verdana" size="2"> Notes:</font></td>
<td>
<textarea name="notes" rows="3" cols="30"
wrap="soft"><
<?=$HTTP_POST_VARS['notes']?>
></textarea>
</td>
</tr>
<tr>
<td height="65"><font color="#FFFFFF" face="Verdana" size="2">
<input type="submit" name="submit2" value="Register">
<input type="hidden" name="required2" value="login,password1,password2,name2,email2">
</font></td>
</tr>
</table>
</form>
</blockquote>
</td>
</tr>
</table>
</div>
</table>
<p>
<?php
if (!file_exists("test.dat")) {
print "oops, this file doesn't exist.";
exit;
}
//The file is readable.
if (!is_writeable("test.dat")) {
print "This file is not writeable!";
exit;
}
//The file is readable.
?>
<?php
$login = 'login';
$password1 = 'password1';
$password2 = 'password2';
$name2 = 'name2';
$email2 = 'email2';
$country = 'country';
$age = 'age';
$state = 'state';
$age = 'age';
$sex = 'sex';
$status = 'status';
$occupation = 'occupation';
$edjabberid = 'edjabberid';
$quote = 'quote';
$hobbies = 'hobbies';
$news = 'news';
$notes = 'notes';
$fp = fopen("test.dat","a");
flock ($fp2,2);
if(!$fp) {
print "error! The file could not be opened";
exit;
}
$stringtowrite=$login'|'$password1'|'$password2'|'$name2'|'$email2'|'$country'|'$age'|'$state'|'$age'|'$sex'|'$status'|'$occupation'|'$edjabberid'|'$quote'|'$hobbies'|'$news"|'$notes;
fwrite($fp, $stringtowrite);
sleep(20);
flock($fp2,3);
fclose($fp);
?>