Jump to content

Recommended Posts

Im trying to submit a form using this script, however nothing shows up on the page, does anyone know why it's not working?

 

Thanks

 

<?php 

// Connects to your Database 
mysql_connect("localhost","xxxx","xxxx") or die(mysql_error()); //CHANGE ME BACK!!!!!
mysql_select_db("xxxx") or die(mysql_error());  

//This code runs if the form has been submitted
if (isset($_POST['submit'])) { 

$date = date("y-m-d H:i:s");

$insert = sprintf("INSERT INTO members set
title = '%s' ,
body = '%s',
image = '%s',
category = '%s',
date = '%s'
",
mysql_real_escape_string($_POST['title']),
mysql_real_escape_string($_POST['body']),
mysql_real_escape_string($_POST['image']),
mysql_real_escape_string($_POST['category']),
mysql_real_escape_string($date])
);
$add_member = mysql_query($insert) or die(mysql_error()); 

?>
<p>Article posted</p>
<?php 
} 
else 
{   
?>

Yeah Is $_POST['submit'] is set, and the else is for when the page is submitted, the message: 'Article Posted' comes up.

 

Would it help if I posted the entire html script?

 

The way I see it, "article posted comes up" when $_POST['submit'] is set. Also close your else block (I don't know if you have done it in your code)

Blank pages are either caused by code that contains a fatal parse error (a parse error will prevent the code on the page from being executed) or by code that does not output anything on the page.

 

If both your if(){} and else{} statements output something, it is likely you are getting a fatal parse error. Are you developing and debugging your php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini (and you have verified these settings using a phpinfo() statement in case the php.ini that you are changing is not the one that php is using) so that php would display all the errors it detects?

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.