Jump to content

Recommended Posts

Hopefully last time today

 

I have a form where users can input items

If a text area is empty, it still inputs the name of the field into the database.

 

How can I make it so that if there is 4 items on the page, and only 1 is filled out, the only thing that gets entered

is the field with something in it?

 

Does that make sense?

 

Here is what I have now that enters everything regardless if something was entered or not

while (list ($name,$val) = @each ($_POST['pick_'])) { 	
//while (list ($name,$val) = @each (mysql_real_escape_string($_POST['pick_']))) { 
$sport = $_POST['sport'];
$active = $_POST['yr']."-".$_POST['month']."-".$_POST['day'];
$spl_date = $_POST['yr_spl']."-".$_POST['month_spl']."-".$_POST['day_spl'];

$val = stripslashes($val);
$val = mysql_real_escape_string($val);

$sql = "INSERT INTO dailypicks1(sport, package, picks, active, month_spl) VALUES(
				'$sport',
				'$name',
				'$val',
				'$active',
				'$spl_date');";
				mysql_query($sql)
				or die("Sorry, there was a problem creating your account ".mysql_error());
}

 

Meaning, if $name's $va is nothing, name or value doesn't go into the database, but the rest of the form does.

 

Thanks in advance

 

 

Link to comment
https://forums.phpfreaks.com/topic/137721-solved-empty-post-dont-enter/
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.