Jason Yu
asked on
signup.php page doesn't work
I have a signup.php page being used for collect online subscriber's email. The code is as below.
When I comment out line 31 -43, it can show part of the page, but when I enable these lines, it doesn't show anything, Could somebody help me take a look?
Thank you.
When I comment out line 31 -43, it can show part of the page, but when I enable these lines, it doesn't show anything, Could somebody help me take a look?
Thank you.
[root@point logs]# vi /var/www/bbemod/signup.php
<?php include "header.php"; ?>
<div class="umTop">Signup for newsletter</div>
<div class="umcont">
<?php
if (isset($_GET['addr']))
{
$email = $_GET['addr'];
if (validate_email_addr($email))
{
Noemail::delete($email);
$sub = new Subscriber();
if (! Subscriber::find($email, $sub)) {
$sub->email_addr = $email;
Subscriber::save($sub);
}
echo "<p>Thank you. " . $email . " has been added to our subscriber list</p>";
}
else {
echo '<p>You must enter a valid email address. Please <a href="' . $_SERVER['PHP_SELF'] . '">try again</a></p>';
}
}
else {
<form action="signup.php" method="GET">
<input type="hidden" name="reason" value="Unsubscribe" >
<p class="bulletText pb10">Email</p>
<p class="pb15">
<input name="addr" type="text" class="textBox" value="Enter your email here"
onfocus="javascript:if(this.value=='Enter your email here'){this.value=''}"
onblur="javascript:if(this.value==''){this.value='Enter your email here'}" size="20" >
</p>
<p class="pb15">
<input type="submit" name="signup" value="" class="signUp"/>
</p>
</form>
}
?>
</div>
<?php include "footer.php"; ?>
ASKER
I didn't get the point, you meant this line has problem:
echo '<p>You must enter a valid email address. Please <a href="' . $_SERVER['PHP_SELF'] . '">try again</a></p>';
echo '<p>You must enter a valid email address. Please <a href="' . $_SERVER['PHP_SELF'] . '">try again</a></p>';
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI, Experts, thank you all for your efforts, I got it resolved by accepting Chris' solution.
"Just take lines 31-45 out of the PHP code block, so your code would look like this:"
by taking these lines out of php section, it works perfectly.
"
<form action="signup.php" method="GET">
<input type="hidden" name="reason" value="Unsubscribe" >
<p class="bulletText pb10">Email</p>
<p class="pb15">
<input name="addr" type="text" class="textBox" value="Enter your email here"
onfocus="javascript:if(thi s.value==' Enter your email here'){this.value=''}"
onblur="javascript:if(this .value=='' ){this.val ue='Enter your email here'}" size="20" >
</p>
<p class="pb15">
<input type="submit" name="signup" value="" class="signUp"/>
</p>
</form>
"
I will read the link Ray Paseur brought and sincere thanks for all the helpful replies and suggestions. You guys are the best!
"Just take lines 31-45 out of the PHP code block, so your code would look like this:"
by taking these lines out of php section, it works perfectly.
"
<form action="signup.php" method="GET">
<input type="hidden" name="reason" value="Unsubscribe" >
<p class="bulletText pb10">Email</p>
<p class="pb15">
<input name="addr" type="text" class="textBox" value="Enter your email here"
onfocus="javascript:if(thi
onblur="javascript:if(this
</p>
<p class="pb15">
<input type="submit" name="signup" value="" class="signUp"/>
</p>
</form>
"
I will read the link Ray Paseur brought and sincere thanks for all the helpful replies and suggestions. You guys are the best!
Since you are mixing PHP and HTML code, you have to remember that the PHP is running on the server, and the HTML is interpreted on the client (i.e. browser).
As a result, that section of code needs to be "echo 'ed" out or the PHP is probably mal-formed.
look at the way line 26 is setup. PHP is echo'ing out the HTML code.
Let me know if you need further explanation.
Ben