Welcome! Log In Create A New Profile

Advanced

Please assist Inserting data into insert.php

Posted by Domdice1 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Please assist Inserting data into insert.php
October 29, 2012 10:19PM
if(isset($_POST['Submit'])){ //catch the submit action and below declare avriables to catch the form data
$rm_disc = $_POST['room_disc'];
$rm_price=$_POST['room_price'];
$res_name = $_POST['res_name'];


//select datababase and update reservation table
$check_id = "SELECT * FROM reservation_info WHERE res_name = '$res_name'";

$result = mysql_query($check_id)
or die(mysql_error());

if ($result) { //test
echo "The Reservation Id $res_name already exists! Book in under another Reservation <a href='insert.php'> Retry </a><br>";
}
else{
$query = "INSERT INTO reservation_info(room_disc, room_price, res_name) VALUES ('$rm_disc', '$rm_price', '$res_name'winking smiley";
$result = mysql_query($store)
or die("Query failed!"winking smiley;
echo "The Reservation for $res_name, with a price of $ttl_price has been booked!";
}
avatar
Mac
Re: Please assist Inserting data into insert.php
October 30, 2012 07:16AM
Use formatted code button when posting code as explained in tut letter!!!!!!!!!!!!!!!
Re: Please assist Inserting data into insert.php
October 30, 2012 09:04AM
Hi,

I can see 1 mistake and & 1 .. well mater of opinion.

The mistake: You create yout INSERT statement with $query, but you call your $result query with $store...
Either change $query to $store or $store to $query in those 2 statements.

Then the matter of opinion, you check if the user making the booking isn't already in your DB TABLE...
That to me is not right.. you mean to say if a person booked once they can never book again? You will loose alot of money.

I will leave that part out but if you really wanna check then make it an ANDALSO with name & surname being the same, alot of people have same name but not same name & surname... or use id number or cell number to check.
Sorry, only registered users may post in this forum.

Click here to login