Jump to content

Poll error


Liru

Recommended Posts

My code:

 

			  <?php  
  
if ($_REQUEST['poll_question']){  
  
include 'database_info.php';  
  
//Seeing how many options were filled in  
  
switch ($_REQUEST['poll_question']){  
   case ($_REQUEST['option_4'] != ''):  
       $options = $_REQUEST['option_1'] ." | ".$_REQUEST['option_2'] ." | ".$_REQUEST['option_3'] ." | ".$_REQUEST['option_4'];  
       break;  
   case ($_REQUEST['option_3'] !=''):  
       $options = $_REQUEST['option_1'] ." | ".$_REQUEST['option_2'] ." | ".$_REQUEST['option_3'];  
       break;  
   case ($_REQUEST['option_2'] !=''):  
       $options = $_REQUEST['option_1'] ." | ".$_REQUEST['option_2'];  
       break;  
   case ($_REQUEST['option_1'] !=''):  
      die("The poll needs more then one option.");  
      break;  
  
mysql_query = ("INSERT INTO poll VALUES ('','".mysql_real_escape_string($_REQUEST['poll_question']."', '".mysql_real_escape_string($options)."', ".time().")");  
echo "The poll has been created.";  
}else{  
  <form name="poll_submit" action="<?php $_SERVER[php_SELF];?>" method="POST">  
Poll Question: <input type="text" name="poll_question">  
<br />  
Poll Options:   
<br />  
<input type="text" name="option_1">  
<br />  
<input type="text" name="option_2">  
<br />  
<input type="text" name="option_3">  
<br />  
<input type="text" name="option_4">  
<br />  
<input type="submit">  
</form>  
}  ?>  

 

What did I do wrong? I get this error.

 

Parse error: syntax error, unexpected '=' in /home/moviefli/spambb.com/index.php on line 83

Link to comment
Share on other sites

mysql_query("INSERT

not

mysql_query = ("INSERT

 

switch() statement is missing a closing curly brace }

 

For the last } else {, you try to send html to the browser without a closing ?> tag.

 

Fixing the above will necessitate opening <?php tag before the very last closing curly brace

 

Don't use $_SERVER['PHP_SELF'] as a form action. It presents a known XSS vulnerability. Use action="" instead.

 

There might be others, but I *think* that's all of them.

Link to comment
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.