Not inserting into database (php)

Ok here is my form page:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>calendar update</title>
<link href="style.css" rel="stylesheet" type="text/css">

</head>

<body bgcolor="#000000" leftmargin="0" topmargin="0">
<div id="Layer2" style="position:absolute; left:14px; top:-8px; width:654px; height:223px; z-index:2">
  <form name="form1" method="post" action="calendarinsert.php">
    <p align="center"><br>
      <br>
      <span><strong>Calendar Update Page </strong> </span></p>
    <table width="95%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td >Date : </td>
        <td ><select name="date1" id="date1">
            <option>Jan</option>
            <option>Feb</option>
            <option>Mar</option>
            <option>Apr</option>
            <option>May</option>
            <option>Jun</option>
            <option>Jul</option>
            <option>Aug</option>
            <option>Sep</option>
            <option>Oct</option>
            <option>Nov</option>
            <option>Dec</option>
          </select>
            <select name="date2" id="date2">
              <option>1</option>
              <option>2</option>
              <option>3</option>
              <option>4</option>
              <option>5</option>
              <option>6</option>
              <option>7</option>
              <option>8</option>
              <option>9</option>
              <option>10</option>
              <option>11</option>
              <option>12</option>
              <option>13</option>
              <option>14</option>
              <option>15</option>
              <option>16</option>
              <option>17</option>
              <option>18</option>
              <option>19</option>
              <option>20</option>
              <option>21</option>
              <option>22</option>
              <option>23</option>
              <option>24</option>
              <option>25</option>
              <option>26</option>
              <option>27</option>
              <option>28</option>
              <option>29</option>
              <option>30</option>
              <option>31</option>
            </select>
            <select name="date3" id="date3">
              <option>04</option>
              <option>05</option>
              <option>06</option>
              <option>07</option>
              <option>08</option>
          </select></td>
      </tr>
      <tr>
        <td >Subject:</td>
        <td ><input name="subject" type="text" id="subject" size="50"></td>
      </tr>
      <tr>
        <td >Content:</td>
        <td ><textarea name="content" cols="50" rows="4" id="content"></textarea></td>
      </tr>
      <tr>
        <td >Image Name(include extention):</td>
        <td ><input name="image" type="text" id="image" size="25"></td>
      </tr>
      <tr>
        <td >&nbsp;</td>
        <td ><input type="submit" name="Submit" value="Submit">
        <input type="reset" name="Reset" value="Reset"></td>
      </tr>
    </table>
    <p>Remember the image needs to be uploaded before you will be able to see it. </p>
    <p><br>
    </p>
  </form>
</div>
<table width="780" height="297" border="0" cellpadding="0" cellspacing="0" bgcolor="#00A0DE">
  <tr>
    <td height="102"><div align="center"><span class="style4 style3 style11"><br>
  <br>
      </span></div></td>
  </tr>
</table>
<?php
include ('templates/links.inc');
?>
</body>
</html>

Here is my insert script:


<?php
if (isset(?_POST['submit'])){
$message = NULL;
			
if(empty($_Post['subject'])){
$subject = FALSE;
$message .= 'You forgot the subject';
}else{
$subject = $_POST['subject'];
}
if(empty($_Post['content'])){
$content = FALSE;
$message .= 'You forgot the content';
}else{
$content = $_POST['content'];
}
}
if($subject && $content){
require_once('mysql_connect.php');
				
$query = "INSERT INTO calendar (date, subject, content, image)
VALUES ('$date1 . $date2 . $date3' , '$subject' , '$content' , '$image')";
$result = @mysql_query($query);
				
if($result){
echo 'Event successfully entered!!!';
exit();
}else{
$message = 'System Error, Contact Nathan, Sorry;)'; 
}
				
mysql_close();
				
}else{
$message .= 'Please Try Again';
}
					
}
				
if(isset($message)){
echo $message;
}
?>

Im not getting any errors the page is just blank when i submit the data.

bump

See anything wrong with this?
<?php
if (isset(?_POST[‘submit’])){

hint ‘?’

heh … we’ve all been there :stuck_out_tongue:

if you just turned error reporting to e_all it might have picked that up for ya :slight_smile:

lol ok ill try it, im not denying that im a noob;)

Ok now im getting the else statement at the very bottom where i run the query, the one that says system error, contact Nathan, sorry. What am i doing wrong? Please help:(


<?php 
if (isset($_POST['submit'])){ 
$message = NULL; 
             
if(empty($_Post['subject'])){ 
$subject = FALSE; 
$message .= 'You forgot the subject'; 
}else{ 
$subject = $_POST['subject']; 
} 
if(empty($_Post['content'])){ 
$content = FALSE; 
$message .= 'You forgot the content'; 
}else{ 
$content = $_POST['content']; 
} 
} 
if($subject && $content){ 
require_once('mysql_connect.php'); 
                 
$query = "INSERT INTO calendar (date, subject, content, image) 
VALUES ('$date1 . $date2 . $date3' , '$subject' , '$content' , '$image')"; 
$result = mysql_query($query); 
                 
if($result){ 
echo 'Event successfully entered!!!'; 
exit(); 
}else{ 
$message = 'System Error, Contact Nathan, Sorry;)'; 
} 
                 
mysql_close(); 
                 
}else{ 
$message .= 'Please Try Again'; 
} 
                     
} 
                 
if(isset($message)){ 
echo $message; 
} 
?> 


I re wrote it slightly - see if this helps:


<?php
require_once('mysql_connect.php');

if (isset($_POST['submit'])){	
	
	$subject = trim($_POST['subject']);
	$content = trim($_POST['content']);
	
	if($subject = ""){		
		echo = 'You forgot the subject';
		@mysql_close();	
		exit();
	}
	if($content = ""){		
		echo = 'You forgot the content';
		@mysql_close();	
		exit();
	}
	
	$sql = "INSERT INTO calendar (date, subject, content, image) VALUES ('$date1 . $date2 . $date3' , '$subject' , '$content' , '$image')";
	if ($result = @mysql_query($sql)){
		echo 'Event successfully entered!!!';
		@mysql_close();	
		exit();
	}else{
		echo = 'System Error, Contact Nathan, Sorry ;)';
		@mysql_close();	
	}
					 
}else{
	echo = 'Please Try Again';
}

?> 

Note when using $_SERVER[’’]; $_POST[’’]; $_GET[’’]; These are all uppercase. You were using $_Post, which is not the same as $_POST.

Parse error: parse error, expecting ','' or‘;’’ in /home/theedgem/public_html/secure/calendarinsert.php on line 24


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>calendar update</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#000000" leftmargin="0" topmargin="0">
<table width="780" height="297" border="0" cellpadding="0" cellspacing="0" bgcolor="#00A0DE">
  <tr>
    <td height="102"><div align="center"><span class="style1">
	
	<?php 
require_once('mysql_connect.php'); 

if (isset($_POST['submit'])){     
     
    $subject = trim($_POST['subject']); 
    $content = trim($_POST['content']); 
     
    if($subject = ""){         
        echo = 'You forgot the subject'; 
        @mysql_close();     
        exit(); 
    } 
    if($content = ""){         
        echo = 'You forgot the content'; 
        @mysql_close();     
        exit(); 
    } 
     
    $sql = "INSERT INTO calendar (date, subject, content, image) VALUES ('$date1 . $date2 . $date3' , '$subject' , '$content' , '$image')"; 
    if ($result = @mysql_query($sql)){ 
        echo 'Event successfully entered!!!'; 
        @mysql_close();     
        exit(); 
    }else{ 
        echo = 'System Error, Contact Nathan, Sorry ;)'; 
        @mysql_close();     
    } 
                     
}else{ 
    echo = 'Please Try Again'; 
} 

?> 
					
	
				
				
	
	
      </span></div></td>
  </tr>
</table>
<?php
include ('templates/links.inc');
?>
</body>
</html>

thanks for the help;)

bump

What are the contents of the require and include files? Make sure to change the values of the password, db, etc. of the db require. Don’t want those going public…

o, i dont need that include links part in there, that goes to another page, i accidently put it on there. Whats up with the error im getting though, do you know marble?

I had a goof in there, not sure if that is the error or not.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>calendar update</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#000000" leftmargin="0" topmargin="0">
<table width="780" height="297" border="0" cellpadding="0" cellspacing="0" bgcolor="#00A0DE">
  <tr>
    <td height="102"><div align="center"><span class="style1">
    
<?php
require_once 'mysql_connect.php';

if ( isset($_POST['submit']) ){  
     
    $subject = trim($_POST['subject']);
    $content = trim($_POST['content']);
     
    if($subject == ""){         
        echo  'You forgot the subject';
        @mysql_close();     
        exit();
    }
    if($content == ""){         
        echo  'You forgot the content';
        @mysql_close();     
        exit();
    }
     
    $sql = "INSERT INTO calendar (date, subject, content, image) VALUES ('$date1 . $date2 . $date3' , '$subject' , '$content' , '$image')";
    if ($result = @mysql_query($sql)){
        echo 'Event successfully entered!!!';
        @mysql_close();     
        exit();
    }else{
        echo  'System Error, Contact Nathan, Sorry ;)';
        @mysql_close();     
    }
                     
}else{
    echo  'Please Try Again';
}

?>
      </span></div></td>
  </tr>
</table>
</body>
</html> 

that code doesnt work either, defaults to ‘please try again’

Where is the form?

its on the first post of this thread

Try using $_POST[‘Submit’] instead of $_POST[‘submit’]

Ok that worked, but now im getting the else statement ‘system error please contact nathan’

How are you connecting to the database? I am assuming it’s in the required page, but I can’t see it to review it…

yes is the mysql_connect page, i cant show it to you sorry, passwords on it