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
https://forums.phpfreaks.com/topic/220295-poll-error/
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
https://forums.phpfreaks.com/topic/220295-poll-error/#findComment-1141589
Share on other sites

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.