Jump to content

syntax error, unexpected '}' in C:\wamp\www\emailsubunsub\manage.php on line 59


shwetapandit

Recommended Posts

hi.....

I m new in php.i have syntax error, unexpected '}' in C:\wamp\www\emailsubunsub\manage.php on line 59 error in my snippet.if anyone fi bug or suggest me same then it would be great help for me.

<?php
include 'subscribe_include.php';
//determine if they need to see the form or not
if(!$_POST){
//they need to see the form,so create the form block
$display_block=<<<END_OF_BLOCK
<form method='POST' action-"$_SERVER[PHP_SELF]">

Your E-mail address :
<input type="email" id="email" name="email"
size="40" maxlength="150"/>

<fieldset>
<legend>Action :</legend><br/>
Subscribe :
<input type="radio" id="action_sub" name="action"
 value="sub" checked/><br/>
Unsubscribe :
<input type="radio" id="action_unsub" name="action"
 value="unsub"/>
</fieldset>

<button type="submit" name="submit"
value="submit">Submit</button>
</form>
END_OF_BLOCK;
}
else if(($_POST)&&($_POST['action']=="sub")){
//trying to subscribe;validate e-mail address
if(($_POST['email']==" ")){
header("Location:manage.php");
exit;}
else{
//connect to database
doDB();

//check that mail is in list
emailChecker($_POST['email']);

//get number of results and do action
if(mysqli_num_rows($check_res)<1){

//free result
mysqli_free_result($check_res);

//add record
$add_sql="INSERT INTO Subscribers_DB(email)
VALUES ('".$safe_email."')";
$add_res=mysqli_query($mysqli,$add_sql)
or die(mysqli_error($mysqli));
$display_block="<p>Thanks for signing up</p>";
      
//close connection to mysql
mysqli_close($mysqli);
}
else{
//print failure message
$display_block="<p>You are already subscribed!</p>"
   }  
 }
}
else if(($_POST)&&($_POST['action']=="unsub")){
//trying to unsubscribe;validate e-mail address
if($_POST['email']==""){
header("Location:manage.php");
exit;
}
else{
//connect to database
doDB();

//check that email is in list
emailChecker($_POST['email']);

//get number of results and do action
if(mysqli_num_rows($check_res)<1){
//free result
mysqli_free_result($check_res);

//print failure message
$display_block="<p>Couldn,t find your address!</p><p>No action was taken</p>";
}
else{
//get value of id from result
while($row=mysqli_fetch_array($check_res)){
$id=$row['id'];
}

//unsubscribe the address
$del_sql="DELETE FROM Subscribers_db WHERE id=".$id;
$del_res=mysqli_query($mysqli,$del_sql)or die(mysqli_error($mysqli));
$display_block="<p>You're unsubscribed!</p>";
}
mysqli_close($mysqli);
}
}
?>
<html>
<head>
<title>Subscribe/Unsubscribe to a mailing list</title>
</head>
<body>
<h1>Subscribe/Unsubscribe to a mailing list</h1>
<?php
echo "$display_block";?>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.