Jump to content

php help


onthespot

Recommended Posts

[code]<form action="insert12.php" method="post">
Title: <input type="text" name="title"  value"<? echo $form->value("title"); ?>" />
Text: <input type="text" name="text" value"<? echo $form->value("text"); ?>" />
<input type="submit" />
</form>
<?php
if(empty($title) || empty($text)) exit("You didn't completely fill in the form!");
// we're presuming here that you used 'title' and 'text' as the names for your form elements
$title = addslashes($title);
$text = addslashes($text);
// add slashes to the sent info so no escape characters are around (they'll possibly bust the script)
mysql_query("INSERT INTO news (title,text) VALUES ('$title','$text')"); ?>[/code]

this code is allowing me to submit the news, however, its not showing a message saying news piece added, and its always showing the "you didnt fill in form" even when the title and text are not empty!

any ideas
Link to comment
Share on other sites

It appears register globals is off (which is good!)

try:

$title = isset($_POST['title']) ? addslashes($_POST['title']) : NULL;
$text = isset($_POST['text']) ? addslashes($_POST['text']) : NULL;

if (is_null($title) || is_null($text)) {
exit("You didn't completely fill in the form!");
}

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