9 Replies - 4845 Views - Last Post: 03 October 2011 - 10:55 PM Rate Topic: -----

#1 wonderlhily  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 31
  • Joined: 19-August 11

Selected time in combo box not inserted to database

Posted 03 October 2011 - 02:40 AM

<?php include("C:/xampp/htdocs/mySalon/connect_database.php"); ?>

<?php
session_start();

if(isset ($_POST ['submit']) && ($_POST ['completeName']) && ($_POST ['mobileNumber']) && ($_POST ['emailAddress'])&& ($_POST ['date'])&& ($_POST ['time']) ){

$submit = $_POST['submit'];

//form data

$completeName = strip_tags ($_POST ['completeName']);
$mobileNumber = strip_tags ($_POST ['mobileNumber']);
$emailAddress = strip_tags ($_POST ['emailAddress']);
$date = $_POST ['date'];
$time = $_POST ['time'];



if ($submit)
{
		if (!empty($_POST['completeName']) && ($_POST['mobileNumber']) && ($_POST['emailAddress']) && ($_POST['date']) && ($_POST['time']) ) {
			$query="SELECT * FROM services_reserve WHERE completeName = '".$completeName."' 
			AND mobileNumber = '".$mobileNumber."' 
			AND emailAddress = '".$emailAddress."' 
			AND date_reserve = '".$date."'
			AND time_reserve = '".$time."'";
			$result = mysql_query($query);
			@$num_rows = mysql_num_rows($result);
			if ($num_rows == 0) {
				$query1="INSERT INTO services_reserve (completeName,mobileNumber,emailAddress,date_reserve,time_reserve)
			VALUES ('$_POST[completeName]','$_POST[mobileNumber]','$_POST[emailAddress]','$_POST[date]','$_POST[time]')";
		$result1 = mysql_query($query1);
				if(@result1 == 0) {?> 
				<script language="javascript">
				alert("Reservation detail has been send.Please check your email address for the confirmation.");
                </script> 
                <?
				}
				else { ?> <script language="javascript">
				alert("No record added.");
                </script><? }
		}
		else
			echo " not submitted";
	}
	else 
	echo "Please fill in <b>all</b> fields!";
}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reservation</title>
<link href="stylesheet/default.css" rel="stylesheet" type="text/css" />

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>


<script type="text/javascript">
<!--
function SelectDate()
{
    D = document.getElementById('Date').value;
    if(D){
        D = D.split('/');
    }else{
        Dat = new Date();
        D = new Array(Dat.getDay(), Dat.getMonth(), Dat.getFullYear());
    }
    win = window.open("date-picker.html","win","status=no,scrollbars=no,toolbar=no,menubar=no,height=150,width=150");
    if (parseInt(navigator.appVersion) == 2 && navigator.appName == "Netscape")
        win = window.open("date-picker.html","win","status=yes,height=325,width=250");
        //win'MakeDate',D[2], D[1],D[0], 'SetDate');
        win.MakeDate(D[2], D[1], D[0]);
}
function SetDate(Day, Month, Year)
{
    document.getElementById('Date').value = Day + '/' + Month + '/' + Year;
}
//-->
</script>
</head>

<body>

     
<div id="page">
  <div id="content">
<div id="welcome" class="boxed2">
			<h1 class="title style17">Making An Online Reservation</h1>
            <p align="left">&nbsp;</p>
            <p align="left">Please complete the following form and                                           a confirmation email will be sent to you otherwise a representative will contact you within                                           24 hours to confirm your reservation details. </p>
            <p align="left">&nbsp;</p>
            <p align="left">To make reservations requests                                           with less than 24 hours advance notice,                                           to cancel a reservation or if you                                           have any questions regarding your reservation,                                           please <a href="http://www.hinamana.com/contact.php"><strong>contact                                           us</strong></a> directly at<strong> (02) 542-6478</strong></p>
            <p align="left">&nbsp;</p>
            <p align="left" class="style30">Note: Keith Louise Salon and Spa accomodate only 10 reservations a day.</p>
      <p class="style28">&nbsp;</p>
<div class="content">
            <p><h4 class="style29">Please Fill Out This Form To Request A Reservation</h4>
            <p class="style29">&nbsp;</p>
            </p>
          
            <form action="reservation.php" method="post">
                <table width="400" border="0" style="font-size:12px">
           
                  <tr>
                    <td><span class="style13">Complete Name:</span></td>
                    <td><input name="completeName" type="text" size="25"/></td>
                </tr>
             
                  <tr>
                    <td><span class="style13">Mobile Number:</span></td>
                    <td><input type="text" name="mobileNumber" size="25"/></td>
                  </tr>
                  <tr>
                  <td><span class="style13">Email Address:</span></td>
                <td><input type="text" name="emailAddress" size="25"/></td>
              </tr>
              </table>
                <p>&nbsp;</p>
                <p>&nbsp;</p>
                 <fieldset><legend class="style29">Check Available Time and Date</legend>
              <p>&nbsp;</p>
                <p align="center">
                  <input type="text" name="date" id="Date"/>
                  <a href="javascript:SelectDate()">
                  <img src="images/calendar_icon.gif"/></a>
                  <select name="time" id="time">
                 
                    <option value=""></option>
                    <option value="">8:00 am</option>
                    <option value="">8:30 am</option>
                    <option value="">9:00 am</option>
                    <option value="">9:30 am</option>
                    <option value="">10:00 am</option>
                    <option value="">10:30 am</option>
                    <option value="">11:00 am</option>
                    <option value="">11:30 am</option>
                    <option value="">12:00 pm</option>
                    <option value="">12:30 pm</option>
                    <option value="">1:00 pm</option>
                    <option value="">1:30 pm</option>
                    <option value="">2:00 pm</option>
                    <option value="">2:30 am</option>
                    <option value="">3:00 pm</option>
                    <option value="">3:30 pm</option>
                    <option value="">4:00 pm</option>
                    <option value="">4:30 pm</option>
                    <option value="">5:00 pm</option>
                    <option value="">5:30 pm</option>
                    <option value="">6:00 pm</option>
                    <option value="">6:30 pm</option>
                    <option value="">7:00 pm</option>
                    <option value="">7:30 pm</option>
                    <option value="">8:00 pm</option>
                    <option value="">8:30 pm</option>
                    <option value="">9:00 pm</option>
                  </select>
                 
                </p>
                <p>&nbsp;</p>
                </fieldset>
                  
              <p>&nbsp;</p>
              <input type="submit" name="submit" value="Reserve"/>
             
            </form>
           
	  </div>
     </div>
     </div>
</div>
</body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: Selected time in combo box not inserted to database

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3633
  • View blog
  • Posts: 5,755
  • Joined: 08-June 10

Re: Selected time in combo box not inserted to database

Posted 03 October 2011 - 03:03 AM

The reason for the problem you are talking about is the value attributes you put on the <option> elememnts. They are all empty strings, and will therefore be considered empty or FALSE if used as boolean expressions.

Either do:
<select ...>
    <option value="theValueSentToPHP">Label shown</option>
</select>


In which case the contents of the value attribute will be sent to PHP.

Or do this:
<select ...>
    <option>theValueSentToPHP</option>
</select>


In which case the text inside the option element will be sent.
Was This Post Helpful? 1
  • +
  • -

#3 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3633
  • View blog
  • Posts: 5,755
  • Joined: 08-June 10

Re: Selected time in combo box not inserted to database

Posted 03 October 2011 - 03:19 AM

Also, while I'm at it, there are just a few of other things about that code you should consider.

First, the way you are using the isset() and empty() functions is not correct. The way you are using them, only the first value will be checked correctly. The others will simply be read as boolean checks, in which case you may get incorrect results. - For instance, if you pass 0 it will be read as FALSE, while an isset() check on it should in fact return TRUE, as it is a value.

The isset() function allows you to pass multiple values to be checked, but the empty() function only takes one and needs to be called for each variable you want to check.
// Incorrect usage: (The way you are doing it.)
if (isset($arr[0]) && ($arr[1]) && ($arr[2])) { }
if (!empty($arr[0]) && ($arr[1]) && ($arr[2])) { }

// Correct usage:
if (isset($arr[0], $arr[1], $arr[2])) { }
if (!empty($arr[0]) && !empty($arr[1]) && !empty($arr[2])) { }



Second, you put the input values into variables, striping tags and such. However, in the following lines you are still using the $_POST array instead of the local variables you just defined. You should either clean and use the $_POST array, or put them in local variables and use them. Mixing them together is just asking for trouble.

Third, your code is wide open to SQL Injection. When using the old mysql_* functions, you should always pass all values through the mysql_real_escape_string function before using them.
$completeName = mysql_real_escape_string($_POST ['completeName']);
$mobileNumber = mysql_real_escape_string($_POST ['mobileNumber']);
$emailAddress = mysql_real_escape_string($_POST ['emailAddress']);
$date = mysql_real_escape_string($_POST ['date']);
$time = mysql_real_escape_string($_POST ['time']);

// AND remember to use THESE variables from now on,
// not the $_POST array!


You could also skip the SQL Injection threat altogether by switching to MySQLi or PDO and using prepared/parameterized statements.

This post has been edited by Atli: 03 October 2011 - 03:22 AM

Was This Post Helpful? 4
  • +
  • -

#4 wonderlhily  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 31
  • Joined: 19-August 11

Re: Selected time in combo box not inserted to database

Posted 03 October 2011 - 06:55 AM

thanks for the knowledge :)

here's the revision of my code.. but i dont know if it is right..I think there's wrong with $arr.. i cant figure it out because im still new to this.

thank you for the help ;)


<?php
session_start();


if(isset ($arr['submit'],$arr ['completeName'],$arr ['mobileNumber'],$arr['emailAddress'],$arr ['date'],$arr ['time']) ){

$submit = $_POST['submit'];

//form data

$completeName = mysql_real_escape_string ($_POST ['completeName']);
$mobileNumber = mysql_real_escape_string ($_POST ['mobileNumber']);
$emailAddress = mysql_real_escape_string ($_POST ['emailAddress']);
$date = mysql_real_escape_string($_POST ['date']);
$time = mysql_real_escape_string($_POST ['time']);



if ($submit)
{
		if (!empty($arr['completeName']) && !empty ($arr['mobileNumber']) && !empty($arr['emailAddress']) && !empty($arr['date']) && !empty($arr['time']) ) {
			$query="SELECT * FROM services_reserve WHERE completeName = '".$completeName."' 
			AND mobileNumber = '".$mobileNumber."' 
			AND emailAddress = '".$emailAddress."' 
			AND date_reserve = '".$date."'
			AND time_reserve = '".$time."'";
			$result = mysql_query($query);
			@$num_rows = mysql_num_rows($result);
			if ($num_rows == 0) {
				$query1="INSERT INTO services_reserve (completeName,mobileNumber,emailAddress,date_reserve,time_reserve)
			VALUES ('$_POST[completeName]','$_POST[mobileNumber]','$_POST[emailAddress]','$_POST[date]','$_POST[time]')";
		$result1 = mysql_query($query1);
				if(@result1 == 0) {?> 
				<script language="javascript">
				alert("Reservation detail has been send.Please check your email address for the confirmation.");
                </script> 
                <?
				}
				else { ?> <script language="javascript">
				alert("No record added.");
                </script><? }
		}
		else
			echo " not submitted";
	}
	else 
	echo "Please fill in <b>all</b> fields!";
}
}
?>



Was This Post Helpful? 0
  • +
  • -

#5 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3633
  • View blog
  • Posts: 5,755
  • Joined: 08-June 10

Re: Selected time in combo box not inserted to database

Posted 03 October 2011 - 07:11 AM

The $arr variable was just a random example I used. You'll have to replace it with the array you actually want to check, which in your case is presumably $_POST.
Was This Post Helpful? 0
  • +
  • -

#6 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: Selected time in combo box not inserted to database

Posted 03 October 2011 - 07:22 AM

Hi,

Atli was just using $arr as an example, you have to actually check for real values being posted. You don't have any $arr variable(that was can see in) in your code. $_POST is an associative array. Values from the array are accessed by their key e.g. $_POST['key'].

What type of field is date_reserve in your table? If it is of type DATE then the expected format is 'YYYY-MM-DD'.

Do a check to see if the query succeeds:
if($result = mysql_query($query))
{

}
else
{
 echo "problem with query $query" . mysql_error();
}



That will allow you to see the query and any error that you are getting from the database.
Was This Post Helpful? 0
  • +
  • -

#7 wonderlhily  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 31
  • Joined: 19-August 11

Re: Selected time in combo box not inserted to database

Posted 03 October 2011 - 08:37 AM

thank you ! Now i know how to use array :)
Was This Post Helpful? 0
  • +
  • -

#8 wonderlhily  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 31
  • Joined: 19-August 11

Re: Selected time in combo box not inserted to database

Posted 03 October 2011 - 10:23 AM

This is now my RESERVATION Form

add im trying to add a select box that when multiple items is selected it will be inserted to database. But my code here can insert only one item.

this is the error :

Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in C:\xampp\htdocs\mySalon\reservation.php on line 17

<?php include("C:/xampp/htdocs/mySalon/connect_database.php"); ?>

<?php
session_start();

if (isset ($_POST['submit'],$_POST['completeName'],$_POST ['mobileNumber'],$_POST ['emailAddress'],$_POST ['date'],$_POST ['time'],$_POST['servicesHairID'],$_POST['termsCondition'])) {

$submit = $_POST['submit'];

//form data

$completeName = mysql_real_escape_string ($_POST ['completeName']);
$mobileNumber = mysql_real_escape_string ($_POST ['mobileNumber']);
$emailAddress = mysql_real_escape_string ($_POST ['emailAddress']);
$date = mysql_real_escape_string($_POST ['date']);
$time = mysql_real_escape_string($_POST ['time']);
$servicesHairID = mysql_real_escape_string ($_POST ['servicesHairID']);
$termsCondition = mysql_real_escape_string ($_POST ['termsCondition']);




if ($submit)
{
		if (!empty($_POST['completeName']) && !empty($_POST['mobileNumber']) && !empty($_POST['emailAddress']) && !empty($_POST['date']) && !empty($_POST['time']) && !empty($_POST['servicesHairID']) && !empty($_POST['termsCondition']) ) {
			$query="SELECT * FROM services_reserve WHERE completeName = '".$completeName."' 
			AND mobileNumber = '".$mobileNumber."' 
			AND emailAddress = '".$emailAddress."' 
			AND date_reserve = '".$date."'
			AND time_reserve = '".$time."'
			AND hairServices ='".$servicesHairID."'
			AND termsCondition ='".$termsCondition."'";
			
			
		
			$result = mysql_query($query);
			@$num_rows = mysql_num_rows($result);
			
			
			
			if ($num_rows == 0) {
				$query1="INSERT INTO services_reserve (completeName,mobileNumber,emailAddress,date_reserve,time_reserve,hairServices,termsCondition)
			VALUES ('$_POST[completeName]','$_POST[mobileNumber]','$_POST[emailAddress]','$_POST[date]','$_POST[time]','$_POST[servicesHairID]','$_POST[termsCondition]')";
			
		$result1 = mysql_query($query1);
				if(@result1 == 0) {?> 
				<script language="javascript">
				alert("Reservation detail has been send.Please check your email address for the confirmation.");
                </script> 
                <?
				}
				else { ?> <script language="javascript">
				alert("No record added.");
                </script><? }
		}
		else
			echo "";
	}
	else 
	echo "Please fill in <b>all</b> fields!";
}
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reservation</title>
<link href="stylesheet/default.css" rel="stylesheet" type="text/css" />

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>



<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style7 {font-size: x-small}
.style9 {color: #FFFFFF}

.style17 {
	font-size: 12%;
	color: #006600;
}
.style28 {
	font-size: 13px;
	color: #666666;
}
.style29 {
	color: #006600;
	font-weight: bold;
}
.style30 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
<script type="text/javascript">
<!--
function SelectDate()
{
    D = document.getElementById('Date').value;
    if(D){
        D = D.split('/');
    }else{
        Dat = new Date();
        D = new Array(Dat.getDay(), Dat.getMonth(), Dat.getFullYear());
    }
    win = window.open("date-picker.html","win","status=no,scrollbars=no,toolbar=no,menubar=no,height=150,width=150");
    if (parseInt(navigator.appVersion) == 2 && navigator.appName == "Netscape")
        win = window.open("date-picker.html","win","status=yes,height=325,width=250");
        //win'MakeDate',D[2], D[1],D[0], 'SetDate');
        win.MakeDate(D[2], D[1], D[0]);
}
function SetDate(Day, Month, Year)
{
    document.getElementById('Date').value = Day + '/' + Month + '/' + Year;
}
//-->
</script>
</head>

<body>
<div id="header">
  <div id="logo">
		<h1>&nbsp;</h1>
  </div>
   
    <ul id="MenuBar1" class="MenuBarHorizontal">
      <li><a href="index.php">Home</a> </li>
      <li><a href="#" class="MenuBarItemSubmenu MenuBarItemSubmenu">Services</a>
        <ul>
          <li><a href="hair_services.php">Hair Services</a></li>
          <li><a href="nail_services.php">Nail Services</a></li>
          <li><a href="massage_services.php">Massage Services</a></li>
          <li><a href="others_services.php">Others Services</a> </li>
        </ul>
      </li>
      <li><a href="#">Reservation</a> </li>
      <li><a href="#" class="MenuBarItemSubmenu">Gallery</a>
        <ul>
          <li><a href="hairStyle.html">Hair Style</a></li>
          <li><a href="nailArt.html">Nail Art</a></li>
        </ul>
      </li>
      <li><a href="contact.php">Contact Us</a></li>
  </ul>
    <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','519','height','171','title','header','src','images/header','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/header' ); //end AC code
    </script>
    <noscript>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="519" height="171" title="header">
      <param name="movie" value="images/header.swf" />
      <param name="quality" value="high" />
      <embed src="images/header.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="519" height="171"></embed>
    </object>
    </noscript>
</div>
</div>
<div id="page">
  <div id="content">
<div id="welcome" class="boxed2">
			<h1 class="title style17">Making An Online Reservation</h1>
            <p align="left">&nbsp;</p>
            <p align="left">Please complete the following form and                                           a confirmation email will be sent to you otherwise a representative will contact you within                                           24 hours to confirm your reservation details. </p>
            <p align="left">&nbsp;</p>
            <p align="left">To make reservations requests                                           with less than 24 hours advance notice,                                           to cancel a reservation or if you                                           have any questions regarding your reservation,                                           please <a href="http://www.hinamana.com/contact.php"><strong>contact                                           us</strong></a> directly at<strong> (02) 542-6478</strong></p>
            <p align="left">&nbsp;</p>
            <p align="left" class="style30">Note: Keith Louise Salon and Spa accomodate only 10 reservations a day.</p>
      <p class="style28">&nbsp;</p>
<div class="content">
            <p><h4 class="style29">Please Fill Out This Form To Request A Reservation</h4>
            <p class="style29">&nbsp;</p>
            </p>
          
            <form action="reservation.php" method="post">
                <table width="400" border="0" style="font-size:12px">
           
                  <tr>
                    <td><span class="style13">Complete Name:</span></td>
                    <td><input name="completeName" type="text" size="25"/></td>
                </tr>
             
                  <tr>
                    <td><span class="style13">Mobile Number:</span></td>
                    <td><input type="text" name="mobileNumber" size="25"/></td>
                  </tr>
                  <tr>
                  <td><span class="style13">Email Address:</span></td>
                <td><input type="text" name="emailAddress" size="25"/></td>
              </tr>
              </table>
                <p>&nbsp;</p>
                <p>&nbsp;</p>
                 <fieldset>
              <legend class="style29">Preffered Date and Time</legend>
              <p>&nbsp;</p>
                <p align="center">
                  <input type="text" name="date" id="Date"/>
                  <a href="javascript:SelectDate()">
                  <img src="images/calendar_icon.gif"/></a>
                  <select name="time" id="time">
                 
                    <option value=""></option>
                    <option value="8:00 am">8:00 am</option>
                    <option value="8:30 am">8:30 am</option>
                    <option value="9:00 am">9:00 am</option>
                    <option value="9:30 am">9:30 am</option>
                    <option value="10:00 am">10:00 am</option>
                    <option value="10:30 am">10:30 am</option>
                    <option value="11:00 am">11:00 am</option>
                    <option value="11:30 am">11:30 am</option>
                    <option value="12:00 pm">12:00 pm</option>
                    <option value="12:00 pm">12:30 pm</option>
                    <option value="1:00 pm">1:00 pm</option>
                    <option value="1:30 pm">1:30 pm</option>
                    <option value="2:00 pm">2:00 pm</option>
                    <option value="2:30 am">2:30 am</option>
                    <option value="3:00 pm">3:00 pm</option>
                    <option value="3:30 pm">3:30 pm</option>
                    <option value="4:00 pm">4:00 pm</option>
                    <option value="4:30 pm">4:30 pm</option>
                    <option value="5:00 pm">5:00 pm</option>
                    <option value="5:30 pm">5:30 pm</option>
                    <option value="6:00 pm">6:00 pm</option>
                    <option value="6:30 pm">6:30 pm</option>
                    <option value="7:00 pm">7:00 pm</option>
                    <option value="7:30 pm">7:30 pm</option>
                    <option value="8:00 pm">8:00 pm</option>
                    <option value="8:30 pm">8:30 pm</option>
                    <option value="9:00 pm">9:00 pm</option>
                  </select>
                  
                </p>
                <p>&nbsp;</p>
                </fieldset>
                <fieldset>
                <legend class="style29">Choose Type of Services</legend>
              <p>&nbsp;</p>
             
               <table width="400" border="0" style="font-size:12px">
           
                  <tr>
                    <td><span class="style13">Hair Services:</span></td>
                    <td><p>
                      <select name="servicesHairID[]" id="servicesHairID" multiple="multiple">
                        <option value="Amino Mint Treatment">Amino Mint Treatment</option>
                        <option value="Cellophane">Cellophane</option>
                        <option value="Fill and Seal Vital Repair">Fill and Seal Vital Repair</option>
                        <option value="Hair Blow Dry">Hair Blow Dry</option>
                        <option value="Hair Color Promo">Hair Color Promo</option>
                        <option value="Hair Hi-Lite">Hair Hi-Lite</option>
                        <option value="Hair Mask">Hair Mask</option>
                        <option value="Hair Perming">Hair Perming</option>
                        <option value="Hair Rebonding any Lenght">Hair Rebonding any lenght</option>
                        <option value="Hair Relax">Hair Relax</option>
                        <option value="Hair Spa">Hair Spa</option>
                        <option value="Haircut">Haircut</option>
                        <option value="Hair Wax">Hair Wax</option>
                        <option value="Hot Oil">Hot Oil </option>
                        <option value="Ionic Keratin Treatment">Ionic Keratin Treatment</option>
                        <option value="Iron Straight">Iron Straight</option>
                        <option value="Keratin Treatment">Keratin Treatment</option>
                        <option value="Loreal Gloss Treatment">Loreal Gloss Treatment</option>
                        <option value="Loreal Hair Color">Loreal Hair Color</option>
                        <option value="Loreal Hair Spa">Loreal Hair Spa</option>
                        <option value="Milk Relax w/ free hot oil and haircut">Milk Relax w/ free hot oil and Haircut</option>
                        <option value="Powerdose">Powerdose</option>
                        <option value="Semi De Lino">Semi De Lino</option>
                        <option value="Semi Permanent Hair Color">Semi Permanent Hair Color</option>
                      
                                            </select>
                      
                     
                   
                    </p>
                    <p>&nbsp; </p></td>
                  </tr>
             
                
              </table>
              </fieldset>
              
                  
              <p>&nbsp;</p>
              <p>&nbsp;</p>
              <input name="termsCondition" type="checkbox" value="check" />
            By clicking the box, you Agree to the <a href="termsCondition.php" target="_blank">Terms and Conditions</a> of Keith Louise Salon and Spa.   
              
              <input type="submit" name="submit" value="Reserve"/>
             
            </form>
           
	  </div>
     </div>
     </div>
  <div id="sidebar">
		<div id="news" class="boxed1">
			<h2 class="title">News &amp; Updates</h2>
			<div class="content">
			 
			</div>
		</div>
	</div>
	<!-- end #sidebar -->
	<div style="clear: both; height: 1px;"></div>
</div>
<!-- end #page -->

<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>

<div id="footer">
	<h6 align="center" class="style7"><span class="title style9">Copyright &copy; 2011 Keith Louise Salon and Spa! Designed by<a href="http://www.facebook.com/welovebarney" > D'otherz Company</a></span></h6>
</div>
</body>
</html>



This post has been edited by wonderlhily: 03 October 2011 - 10:26 AM

Was This Post Helpful? 0
  • +
  • -

#9 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: Selected time in combo box not inserted to database

Posted 03 October 2011 - 11:33 AM

Just as it said, $_POST['servicesHairID'] is an array because your name attribute of the select box is is "servicesHairID[]". mysql_real_escape_string expects a string as an argument. If you are using mysql_real_escape_string you will have to use it on each value as you iterate through your array.
Was This Post Helpful? 0
  • +
  • -

#10 wonderlhily  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 31
  • Joined: 19-August 11

Re: Selected time in combo box not inserted to database

Posted 03 October 2011 - 10:55 PM

Error:Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in C:\xampp\htdocs\mySalon\reservation.php on line 17

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\mySalon\reservation.php on line 18

$servicesHairID = mysql_real_escape_string ($_POST ['servicesHairID']);
foreach ($servicesHairID as $value){
	$value=mysql_real_escape_string($value);
	}


Was This Post Helpful? -1
  • +
  • -

Page 1 of 1