I have a pretty limited knowledge of PHP.
My scenario is:
I want one form to have two (2) submit buttons. I want one button to submit an email to a specific address then redirect to a page, and I want the second one to submit to the same email, then redirect to a different page. I've downloaded some code, so I can't take credit for it, but I'm trying to use my basic knowledge to create and IF and ELSE IF. Right now, I'm just trying to get the code to work at all, so I have the form simply submitting the form data to an email address based on the button that was clicked.
I get the following parse error:
Parse error: syntax error, unexpected T_ELSE in /home/salamone/public_html/sendeail.php on line 65
Code: - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>Sendemail Script</title>
-
</head>
-
<body>
-
-
<?php
-
-
-
-
-
-
$ip = $_POST['ip'];
-
$httpref = $_POST['httpref'];
-
$httpagent = $_POST['httpagent'];
-
$visitor = $_POST['visitor'];
-
$visitormail = $_POST['visitormail'];
-
$notes = $_POST['notes'];
-
$attn = $_POST['attn'];
-
-
-
if (eregi('http:', $notes)) {
-
die ("Do NOT try that! ! ");
-
}
-
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
-
{
-
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
-
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
-
echo $badinput;
-
die ("Go back! ! ");
-
}
-
-
if(empty($visitor) || empty($visitormail) || empty($notes )) {
-
echo "<h2>Use Back - fill in all fields</h2>\n";
-
die ("Use back! ! ");
-
}
-
-
if(isset($_POST["sendmail"]) && trim($_POST["sendmail"])!=='') {
-
-
$todayis = date("l, F j, Y, g:i a") ;
-
-
$attn = $attn ;
-
$subject = $attn;
-
-
$notes = stripcslashes($notes);
-
-
$message = " $todayis [EST] \n
-
Attention: $attn \n
-
Message: $notes \n
-
From: $visitor ($visitormail)\n
-
Additional Info : IP = $ip \n
-
Browser Info: $httpagent \n
-
Referral : $httpref \n
-
";
-
-
$from = "From: $visitormail\r\n";
-
-
-
mail("test1@myemail.com", $subject, $message, $from)
-
-
-
else if(isset($_POST["sendmail2"]) && trim($_POST["sendmail2"])!=='') {
-
$todayis = date("l, F j, Y, g:i a") ;
-
-
$attn = $attn ;
-
$subject = $attn;
-
-
$notes = stripcslashes($notes);
-
-
$message = " $todayis [EST] \n
-
Attention: $attn \n
-
Message: $notes \n
-
From: $visitor ($visitormail)\n
-
Additional Info : IP = $ip \n
-
Browser Info: $httpagent \n
-
Referral : $httpref \n
-
";
-
-
$from = "From: $visitormail\r\n";
-
-
-
mail("test2@myemail.com", $subject, $message, $from)}
-
-
?>
-
</body>
-
</html>
-
If I am missing something? Thanks in advance!
4 1859
Main reason:
You have not closed your if statement with curly brackets. Should be like: - if (x=1) {
-
//do something
-
}
-
elseif (x=2) {
-
//do something else
-
}
-
else {
-
//do yet another thing
-
}
Hope that helps. Welcome to Bytes.
Atli 5,058
Expert 4TB
Hey. Welcome to Bytes!
I see 2 errors there.
On lines #62 and #85 you are missing the semi-colon (;) to end the line.
And, before the "else if " on line #65, you are missing the } to close the if preceding it.
An if structure should look like: -
if {
-
// statementes
-
}
-
else if {
-
// statements
-
}
Yours is like this: -
if {
-
// statementes
-
else if {
-
// statements
-
}
@Atli
Point taken. Thanks. And well done with the ";" pick-up ;)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steven |
last post by:
I got a "Parse error: parse error in ..." in this line:
if(empty($_POST){
.....
But if I fist assign $ssn=$_POST; and then if(empty($ssn){ ... it is
working.
Any advice? Thanks in advance.
|
by: H.L Bai |
last post by:
hi, everybody
i meet a parse error when i used the xml4c.
any proposal is helpful.
The error is following
.../XMLRegionHandler.h:59 parse error before '*'
.../XMLRegionHandler.h:60 parse...
|
by: Vittal |
last post by:
Hello All,
I am trying to compile my application on Red Hat Linux 8 against gcc
3.2.2.
Very first file in application is failing to compile. I tried
compiling my application on Linux 7.2...
|
by: BWIGLEY |
last post by:
Basically I've just started making a game. So far it makes an array
25 by 20 and tries to make five rooms within it.
In scr_make_room() there's parse errors:
20 C:\c\Rooms\Untitled1.c parse error...
|
by: trevor |
last post by:
Incorrect values when using float.Parse(string)
I have discovered a problem with float.Parse(string) not getting values
exactly correct in some circumstances(CSV file source) but in very
similar...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming.
FYI
Although I have called...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming.
FYI
Although I have called this...
|
by: Phaelle |
last post by:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
What does that error mean? I can´t find the mistake!!
In another script, I have got another kind of mistake : parse...
|
by: Lawrence Krubner |
last post by:
Imagine a template system that works by getting a file, as a string, and
then putting it through eval(), something like this:
$formAsString = $controller->command("readFileAndReturnString",...
|
by: goldtech |
last post by:
SAX XML Parse Python error message
Hi,
My first attempt at SAX, but have an error message I need help with.
I cite the error message, code, and xml below.
Be grateful if anyone can tell me...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |