Jump to content

Recommended Posts

Hi,

 

I have got the following script:

 

if ($_POST['userMail'] == true)
{
header( 'Location: emailForm.php' );
}
elseif ($_POST['subjectField'] == true)
{ 
header('Location: emailForm.php?cmd=form2');
}
elseif ($_POST['message'] == true)
{
header('Location: emailForm.php?cmd=form3');
}
elseif (($_POST['userMail'] == true) && ($_POST['subjectField'] == true));
{
header('Location: emailForm.php?cmd=form4');
}
elseif ((($_POST['userMail'] == true) && ($_POST['subjectField'] == true) && ($_POST['message'] == true)));
{
header('Location: emailForm.php?cmd=form5');
}

 

 

But I keep getting an error and cant figure out how to fix it. Any help is much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/163790-unexpected-t_elseif/
Share on other sites

Ok, thanks for your replies, that fixed it. The only thing is, when the checkboxes are ticked on the form on the previous page, it always redirects to emailForm.php?cmd=form5, even when it really should redirect to form 1,2,3 or 4.

 

Here is the code for both pages.

 

case "setup3":

$sendmail_from = $_POST['sendmail_from'];
$subject = $_POST['subject'];
$default = $_POST['default'];

echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sitebuilder - PHP Email Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
body {
background-color: #333333;
}
.style1 {color: #CCCCFF}
.style2 {
font-size: 24px;
font-weight: bold;
}
.style3 {color: #9999FF}
.style4 {color: #FFFFCC}
-->
</style></head>

<body>

<div id="header" style="position:absolute; left:4px; top:3px; width:1000px; height:99px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000;">
  <div align="center" class="style1">
    <pre class="style2">Sitebuilder</pre>
    <pre><strong>PHP Email script </strong></pre>
  </div>
</div>
<div id="Layer1" style="position:absolute; left:4px; top:109px; width:1000px; height:430px; z-index:3">
  <h2 align="center" class="style4"> PHP Email Script </h2>
  <blockquote>

<form action=emailSetup.php?cmd=setup4 method=POST>
<input type=hidden name=agree value=true>';

echo "<input type=hidden name=sendmail_from value=$sendmail_from>";
echo "<input type=hidden name=subject value=$subject>";
echo "<input type=hidden name=default value=$default>";

echo '
<table border=0 align=center>
<tr><td colspan=2>
<tr><td colspan=2 class=style1><b><center>EMAIL SETTINGS</center></b></td></tr>
<tr><td colspan=2><p class=style4>Please select which fields you would like the user to complete when sending a message:</p></td></tr>
<tr><td class=style1>Mail From:</td><td><input type=checkbox name=userMail></td></tr>
<tr><td class=style1>Subject:</td><td><input type=checkbox name=subjectField></td></tr>
<tr><td class=style1>Message:</td><td><input type=checkbox name=message></td></tr>
<tr><td colspan=2><input type=submit name=submit value=submit></td></tr>
</table>
</form>
  </blockquote>
</div>
</body>
</html>
';

break;

case "setup4":

$sendmail_from = $_POST['sendmail_from'];
$subject = $_POST['subject'];
$default = $_POST['default'];
$userMail = $_POST['userMail'];
$subjectField = $_POST['subjectField'];


$filename = "emailAdmin.php";
$fa = fopen( $filename, "w" ) or die("Error opening $filename");
fwrite( $fa, "<?php\n \$data[0]['sendmail_from'] = '$sendmail_from';\n \$data[0]['subject'] = '$subject';\n \$data[0]['default'] = '$default';\n \$data[0]['userMail'] = '$userMail';\n \$data[0]['subjectField'] = '$subjectField';\n?>" );
fclose( $fa );

if ($_POST['userMail'] == true)
{
header( 'Location: emailForm.php' );
}
elseif ($_POST['subjectField'] == true)
{ 
header('Location: emailForm.php?cmd=form2');
}
elseif ($_POST['message'] == true)
{
header('Location: emailForm.php?cmd=form3');
}
elseif (($_POST['userMail'] == true) && ($_POST['subjectField'] == true))
{
header('Location: emailForm.php?cmd=form4');
}
elseif ((($_POST['userMail'] == true) && ($_POST['subjectField'] == true) && ($_POST['message'] == true)));
{
header('Location: emailForm.php?cmd=form5');
}

break;

Link to comment
https://forums.phpfreaks.com/topic/163790-unexpected-t_elseif/#findComment-864231
Share on other sites

in fwrite many n's no reason.. also

 

<?phpn  ? that normal.. must be <?php no n's

 

 

also

 

case "setup4":

??no switch?? whats up with that.. maybe you mean  $_GET['setup4'];

nevermind about switch question.. you must not posted all code.. but elseif goes to end because all above failed.. to evalute

 

because all true at all times.. try this

 

if ($_POST['userMail'] == true)

to

if (isset($_POST['userMail']))

 

elseif ($_POST['subjectField'] == true)

to

elseif (isset($_POST['userMail']))

 

To this to all i can't do it all for you.. try yourself  :D

 

to all IF ELSE use isset.. and remove true.. because it already check if true.. no need to put it waste memory..

Link to comment
https://forums.phpfreaks.com/topic/163790-unexpected-t_elseif/#findComment-864262
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.