Jump to content

Recommended Posts

I need some help here. Basically i am accepting contact information from the user and there are some mandatory fields and some are not.

 

So if user does not fill up these optional form fields then i want the PHP script to enter "Not Mentioned" in the database so when i view the submitted data i see "Not Mentioned" in front of respective labels.

 

I tried my way through simple if else but it was not working.

 

Here is the PHP script for adding in database. I am using Client side Javascript for validating other mandatory fields.

 

<?php

$con = mysql_connect("localhost","root","") or die('Could not connect: ' . mysql_error());
  
@mysql_select_db("contactms", $con);

$sql="INSERT INTO contacts (fname, lname, email, website, mobile, work, home, address, country, city, addedby)
VALUES
('$_POST[txtfirstname]','$_POST[txtlastname]','$_POST[txtemail]','$_POST[txtwebsite]','$_POST[txtmobile]','$_POST[txtwork]','$_POST[txthome]','$_POST[txtaddress]','$_POST[txtcountry]','$_POST[txtcity]','$_POST[txtaddedby]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

mysql_close($con);
header("location:manage.php");

?>

 

Please help, Thanks.

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.