表单页面上的所有内容都很好,但在提交表单后,回显中缺少页脚。我收到了电子邮件,标题就在那里,问题只是页脚。这是整个页面的代码。有两种不同的形式,一种用于连接,另一种用于编辑信息。表格提交后,两者都没有显示页脚。 错误日志说
PHP Parse错误:语法错误,意外'回声' (T_ECHO),期待','或';'
<?
include("config.php");
include("header.php");
if (!$_REQUEST['action']) { ?>
<h1>Join Form</h1>
<div align="justify">
<p>Fill out the form below to join this fanlisting. Please make sure you've read the rules and if you have a website, that you put a link back up to <?=$siteurl?> before joining!</p>
<p>Please note: <strong>this form is for joining only</strong>! If you wish to update your member information, please <a href="join.php?action=update">click here</a>.</p>
<script>
function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}
</script>
<div align="center"><form method="post" action="join.php" onSubmit="submitonce(this)">
<input type="hidden" name="apr" value="-">
<input type="hidden" name="action" value="join">
<table border="0" cellspacing="0" cellpadding="2" width="90%">
<tr></tr><td width="30%">Name:</td>
<td><input type="text" name="name" size="40" class="form"></td>
</tr><tr><td>Email Address:<br>
<strong>Please Note</strong>: <em>All email addresses displayed on the member pages are proctected from SPAM by Javascript.</em></td>
<td><input type="text" name="email" size="40" class="form"><br>
<input type="radio" name="hideemail" value="n" checked> Display My Email Address<br>
<input type="radio" name="hideemail" value="h"> Hide My Email Address</td>
</tr><tr><td>Website:</td>
<td><input type="text" name="url" value="" size="40" class="form"></td>
</tr><tr><td>Country:</td>
<td>
<select name="country" class="form">
<option value="0">Please choose:</option>
<option value="0">___</option>
<option value="USA">United States</option>
<option value="England">England</option>
<option value="Scotland">Scotland</option>
<option value="Wales">Wales</option>
<option value="Ireland">Ireland</option>
<option value="Australia">Australia</option>
<option value="Canada">Canada</option>
<option value="0">___</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antigua/Barbuda">Antigua/Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bosnia">Bosnia</option>
<option value="Botswana">Botswana</option>
<option value="Bouvet Island">Bouvet Island</option>
<option value="Brazil">Brazil</option>
<option value="Brunei">Brunei</option>
</select>
</td>
<? if ($enablefave == 'Y'){ ?>
</tr><tr><td class="small"><?=$whatfave?>:</td>
<td><input type="text" name="fave" size="40" class="form"></td>
<? } ?>
</tr><tr><td>Any comments/questions?</td>
<td><textarea rows="3" name="comments" cols="40" class="form"></textarea> </td>
</tr><tr colspan="2"><td><div align="center"><input type="submit" name="Subtmit Button" value="Join!" size="30" class="button"><input type="reset" name="Reset Button" value="Don't" size="30" class="button"> </div></td>
</tr></table></form></div>
<br>
<div align="center"><p>Powered by <a href="http://nothing-less.net/Nothing/you/script_fanbase.php" target="_blank">PHPFanBase</a> 2.0</p></div>
<? } elseif ($_POST['action'] == "join"){
if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['country'])) {
header( "$siteurl/join.php" );
} elseif (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['country'])) {
echo "<h2>Error</h2><p>Oops, it appears you forgot to enter either your email address, your name or your country. Please press the BACK button in your browser and try again.</P>";
} else {
$hideemail = $_POST['hideemail'];
$name = $_POST['name'];
$email = $_POST['email'];
$url = $_POST['url'];
$country = $_POST['country'];
$comments = $_POST['comments'];
$fave = $_POST['fave'];
$apr = $_POST['apr'];
$query="SELECT id FROM $table WHERE email='$email'";
$result=mysqli_query($connect, $query);
$num=mysqli_num_rows($result);
if ($num == "0"){
if ($emailnotify == 'Y') {
$msg = "Name:\t$name\n";
$msg .= "E-Mail:\t$email\n";
$msg .= "Hide E-Mail:\t$hideemail\n";
$msg .= "URL:\t$url\n";
$msg .= "Country:\t$country\n";
if ($enablefave == 'Y') {
$msg .= "Fave:\t$fave\n";
}
$msg .= "Comments:\t$comments\n";
$msg .= "Sender IP:\t$REMOTE_ADDR\n";
$msg .= "\nLogin to your Admin Panel: $siteurl/admin.php\n";
$recipient = $adminemail;
$subject = "Member - $sitename";
$mailheaders = "From: $email\n";
$mailheaders .= "Reply-To: $email\n\n";
mail($recipient, $subject, $msg, $mailheaders);
}
if ($enablefave == 'Y') {
$query = "INSERT INTO $table values ('','$name','$email','$url','$country','$comments','$hideemail','$apr','$fave')";
} else {
$query = "INSERT INTO $table values ('','$name','$email','$url','$country','$comments','$hideemail','$apr')";
}
mysqli_query($connect, $query);
echo "<p>Thank you, $_POST[name]! You will be added to the members list with the next update. :)</p>";
} else { ?>
<p>Sorry, but this email address is already listed in the database. This means that you're already listed as a member. If you wish to update your member information, please use the <a href="join.php?action=update">Update Form</a>. If you want to see your listing as a member, please <a href="members.php">click here</a>.</p>
<? }
}
} elseif ($_GET['action'] == "update"){ ?>
<div align="justify">
<p>Please use the form below to update your member information. If you wish to join this fanlisting, use the Join Form located <a href="join.php">here</a>. Thanks!</p>
<script>
function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}
</script>
<div align="center"><form method="post" action="join.php" onSubmit="submitonce(this)">
<input type="hidden" name="action" value="sendupdate">
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>Member ID:</td>
<td><input type="text" name="id" size="40" class="form"></td>
</tr><tr><td>Name:</td>
<td><input type="text" name="name" size="40" class="form"></td>
</tr><tr><td>Old Email:</td>
<td><input type="text" name="email" size="40" class="form"></td>
</tr><tr><td>Old URL:</td>
<td><input type="text" name="url" value="http://" size="40" class="form"> </td>
</tr><tr><td>Country:</td>
<td><input type="text" name="country" size="40" class="form"></td>
</tr><tr><td>New Email:</td>
<td><input type="text" name="newemail" size="40" class="form"></td>
</tr><tr><td>New URL:</td>
<td><input type="text" name="newurl" value="http://" size="40" class="form"></td>
</tr><tr><td>Did anything else change?</td>
<td><textarea rows="3" name="comments" cols="40" class="form"></textarea> </td>
</tr><tr colspan="2"><td><div align="center"><input type="submit" name="Subtmit Button" value="Send!" size="30" class="button"><input type="reset" name="Reset Button" value="Don't" size="30" class="button"> </div></td>
</tr></table></form></div>
<? } elseif ($_POST['action'] == "sendupdate"){
if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['country'])) {
header( "$siteurl/join.php?update" );
} elseif (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['country'])) {
echo "<h2>Error</h2><p>Oops, it appears you forgot to enter either your old email address, your name or your country. Please press the BACK button in your browser and try again.</P>";
} else {
$name = $_POST['name'];
$email = $_POST['email'];
$url = $_POST['url'];
$newemail = $_POST['newemail'];
$newurl = $_POST['newurl'];
$country = $_POST['country'];
$comments = $_POST['comments'];
$fave = $_POST['fave'];
$apr = $_POST['apr'];
$msg = "Name:\t$name\n";
$msg .= "Old E-Mail:\t$email\n";
$msg .= "Old URL:\t$url\n";
$msg .= "Country:\t$country\n";
$msg .= "New E-Mail:\t$newemail\n";
$msg .= "New URL:\t$newurl\n";
$msg .= "Other Changes:\t$comments\n";
$msg .= "Sender IP:\t$REMOTE_ADDR\n";
$msg .= "\nLogin to your Admin Panel: $siteurl/admin.php\n";
$recipient = $adminemail;
$subject = "Update Info - $sitename";
$mailheaders = "From: $email\n";
$mailheaders .= "Reply-To: $email\n\n";
mail($recipient, $subject, $msg, $mailheaders);
echo "<p>Thanks, your Update has been sent. I will change your information as soon as possible!</p>";?>
<? } } include("footer.php");?>
答案 0 :(得分:0)
您的代码中某些echo
之前出现语法错误。
检查错误日志中断的行,或者手动设置一些打印或转储。
你应该尝试编写更易读的代码(缩进,不要混合那么多的html和php),因为这是这样的错误的主要来源。
它表示期望','或';',所以它可能是一个未闭合的数组或函数,或类似的东西。您发布的代码不会显示任何静态错误,因此可能会产生动态错误。
这些,例如:
<? if ($enablefave == 'Y'){ ?>
// stuff
<? } elseif ($_POST['action'] == "join"){
这使得您的代码很难跟踪,因此很难跟踪错误。 你有这样的语法:
<?php if ($a == 5): ?>
A is equal to 5
<?php endif; ?>
http://www.php.net/manual/en/control-structures.alternative-syntax.php