Inserting data into database using if else

Codes here !

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Thu Jul 12, 2012 3:48 pm

Inserting data into database using if else

Postby arkingIT » Thu Jul 12, 2012 3:54 pm

//the php is not working, someone please help me

//html form

<form action="while_statement.php" method="post">
Name: <br />
<input type="text" id="name" size="60" name="name" /><br /><br />
Email: <br />
<input type="text" id="email name="email" />
<br /><br />
Phone:<br />
<input type="text" id="phone" name="phone" /><br /><br />
Web Site Address:<br />
<input type="text" id="websiteaddress" name="websiteaddress" />
<br /><br />
<input type="submit" value="submit" name="submit"/>

// php part

$email = $_POST['email'];
$persons_name = $_POST['name'];
$phone = $_POST['phone'];
$website_address = $_POST['websiteaddress'];

$dbc = mysqli_connect('', 'user', 'password', 'dbname')
or die('Error connecting to MySQL server.');

$query = "INSERT INTO free_estimate_c (`email`, `name`, `phone`, `website_address`)" .
"VALUES ('$email', '$persons_name', '$phone', '$website_address')";

if (empty($email) or empty($persons_name) or empty($phone) or empty($website_address)){
echo "<p>Fill in your information</p>";

else if ((!empty($persons_name))&&(!empty($email))&&(!empty($phone))&&(!empty($website_address))){
mysqli_query ($query, $dbc);

Return to “mySQL & php coding”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests