Jump to content

[SOLVED] php processing..


aian04

Recommended Posts

<html>
<head>
<link href="interface design/css.css" rel="stylesheet" type="text/css">
</head>
<body class="bg">
<?php

$datein=$_POST['check-in-date'];
$dayin=$_POST['check-in-day'];
$r_tpe=$_POST['r_category'];
$pac=$_POST['special'];
$checkin = "$datein-$dayin" ;
$nyt=$_POST['nyts'];
$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error());             
$id=$_COOKIE['ID'];          

mysql_connect('localhost', 'root', 'tmc') or die(mysql_error());


mysql_select_db('tgp') or die(mysql_error());

e




//ive got error here in this line
if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')"))
{	print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
print '<b>reservation failed</b>';

print '</div>';
}


else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
 print 'Your Information has been successfully added to the database.';
print '<br><br>';
$result=mysql_insert_id();
print "Your Reservation No. is <b>$result</b>";
print '</div>';
}
mysql_close();
?>
</body>
</html>

ok.. again.. here's the question im trying to validate the reservation forms in my reservation table i got res _id checkin date nyt per stay room no package id and Cid which i get the Cid from cookie when dey login

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/
Share on other sites

try

<html>
<head>
<link href="interface design/css.css" rel="stylesheet" type="text/css">
</head>
<body class="bg">
<?php

$datein=$_POST['check-in-date'];
$dayin=$_POST['check-in-day'];
$r_type=$_POST['r_category'];
$pac=$_POST['special'];
$checkin = "$datein-$dayin" ;
$nyt=$_POST['nyts'];
$id=$_COOKIE['ID'];          

mysql_connect('localhost', 'root', 'tmc') or die(mysql_error());


mysql_select_db('tgp') or die(mysql_error());
$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error());             
$room = $room['r_no'];

//ive got error here in this line
if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')"))
{	print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
print '<b>reservation failed</b>';

print '</div>';
}


else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
 print 'Your Information has been successfully added to the database.';
print '<br><br>';
$result=mysql_insert_id();
print "Your Reservation No. is <b>$result</b>";
print '</div>';
}
mysql_close();
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361012
Share on other sites

ok sori...

SELECT r_no FROM room WHERE r_no ='$r_type'

it will give me three r_no ryt...

so it cant insert in database bcoz the result in that query has a three item

for example the result in column r_no got 1, 2 and 3...

my question is... is it possible to auto select in that 3 item..

auto select from 1 2 and 3 so it will succesfully save in database

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361045
Share on other sites

if you mean insert first found then try this

 

<html>
<head>
<link href="interface design/css.css" rel="stylesheet" type="text/css">
</head>
<body class="bg">
<?php

$datein=$_POST['check-in-date'];
$dayin=$_POST['check-in-day'];
$r_type=$_POST['r_category'];
$pac=$_POST['special'];
$checkin = "$datein-$dayin" ;
$nyt=$_POST['nyts'];
$id=$_COOKIE['ID'];          

mysql_connect('localhost', 'root', 'tmc') or die(mysql_error());

mysql_select_db('tgp') or die(mysql_error());
$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error());             
$found = false;
while ($row = mysql_fetch_assoc($room) || !$found) {
    $room = $row["r_no"];

//ive got error here in this line
if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')"))
{	print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
print '<b>reservation failed</b>';

print '</div>';
}	
else {
$found = true;
print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
 print 'Your Information has been successfully added to the database.';
print '<br><br>';
$result=mysql_insert_id();
print "Your Reservation No. is <b>$result</b>";
print '</div>';
}
}

mysql_close();
?>
</body>
</html>

 

if you mean insert all 3

 

<html>
<head>
<link href="interface design/css.css" rel="stylesheet" type="text/css">
</head>
<body class="bg">
<?php

$datein=$_POST['check-in-date'];
$dayin=$_POST['check-in-day'];
$r_type=$_POST['r_category'];
$pac=$_POST['special'];
$checkin = "$datein-$dayin" ;
$nyt=$_POST['nyts'];
$id=$_COOKIE['ID'];          

mysql_connect('localhost', 'root', 'tmc') or die(mysql_error());

mysql_select_db('tgp') or die(mysql_error());
$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error());             
while ($row = mysql_fetch_assoc($room) ) {
    $room = $row["r_no"];

//ive got error here in this line
if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')"))
{	print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
print '<b>reservation failed</b>';

print '</div>';
}	
else {
print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
 print 'Your Information has been successfully added to the database.';
print '<br><br>';
$result=mysql_insert_id();
print "Your Reservation No. is <b>$result</b>";
print '</div>';
}
}

mysql_close();
?>
</body>
</html>

 

 

EDIT updated

as a note i think your doing this the wrong way.. to start with

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361051
Share on other sites

Ah yeah

will do that is none are found

 

try this

 

<html>
<head>
<link href="interface design/css.css" rel="stylesheet" type="text/css">
</head>
<body class="bg">
<?php

$datein=$_POST['check-in-date'];
$dayin=$_POST['check-in-day'];
$r_type=$_POST['r_category'];
$pac=$_POST['special'];
$checkin = "$datein-$dayin" ;
$nyt=$_POST['nyts'];
$id=$_COOKIE['ID'];          

mysql_connect('localhost', 'root', 'tmc') or die(mysql_error());

mysql_select_db('tgp') or die(mysql_error());
$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error());             
while ($row = mysql_fetch_assoc($room) ) {
    $room = $row["r_no"];

//ive got error here in this line
if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')"))
{	print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
print '<b>reservation failed</b>';

print '</div>';
}	
else {
print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
 print 'Your Information has been successfully added to the database.';
print '<br><br>';
$result=mysql_insert_id();
print "Your Reservation No. is <b>$result</b>";
print '</div>';
break;
}
}

mysql_close();
?>
</body>
</html>

 

Techie out, head killing now!

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361073
Share on other sites

<html>

<head>

<link href="interface design/css.css" rel="stylesheet" type="text/css">

</head>

<body class="bg">

<?php

 

       

 

mysql_connect('localhost', 'root', 'tmc') or die(mysql_error());

 

 

mysql_select_db('tgp') or die(mysql_error());

 

$datein=$_POST['check-in-date'];

$dayin=$_POST['check-in-day'];

$r_type=$_POST['r_category'];

$pac=$_POST['special'];

$checkin = "$datein-$dayin" ;

$nyt=$_POST['nyts'];

$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error());           

$id=$_COOKIE['ID'];

 

 

while ($row = mysql_fetch_assoc($room) ) {

    $room = $row["r_no"];

 

 

 

if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')"))

{ print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';

print '<b>reservation failed</b>';

 

print '</div>';

}

 

 

else {

print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';

print 'Your Information has been successfully added to the database.';

print '<br><br>';

$result=mysql_insert_id();

print "Your Reservation No. is <b>$result</b>";

print '</div>';

}

}

mysql_close();

?>

</body>

</html>

 

i did wat watever u told me

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361130
Share on other sites

ok 1st i have this reservation form for member...

in reservation form i have checkin date, nyts per stay, room category id, packages id

in my database reservation table i have checkin date nyts per stay room_no packacges id and Customer id..

in my database room table i have room category id floor level and room no..

 

now my goal is i want to retrieve the room no in room table using the post category id in the form...

and the customer id will save as their login id... which i get from cookie id..

 

so when the query $room is executed... it will give me three different room no because the room category id is a foreign key from table room category...

what i want is to execute the $room query wich will give me the 1st found room_no..

is it possible..

anyways i really appreciate ur reply.. tnx

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361461
Share on other sites

<html>
<head>
<link href="interface design/css.css" rel="stylesheet" type="text/css">
</head>
<body class="bg">
<?php

         

mysql_connect('localhost', 'root', 'tmc') or die(mysql_error());


mysql_select_db('tgp') or die(mysql_error());

$datein=$_POST['check-in-date'];
$dayin=$_POST['check-in-day'];
$r_type=$_POST['r_category'];
$pac=$_POST['special'];
$checkin = "$datein-$dayin" ;
$nyt=$_POST['nyts'];
$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'order by rand() limit 1")or die(mysql_error());             
$id=$_COOKIE['ID']; 



    
if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt','$room','$pac','$id')"))
{	print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
print '<b>reservation failed</b>';
print '</div>';
}


else {
 print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
 print 'Your Information has been successfully added to the database.';
print '<br><br>';
$result=mysql_insert_id();
print "Your Reservation No. is <b>$result</b>";
print '</div>';

}


mysql_close();
?>
</body>
</html>

 

bro now i can do select 1st found but the problem is its always failed...

even i change the $room into number in insert into reservation stil not workin..

i feel bad.. the php dont want me...

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361844
Share on other sites

have you tried it ?

 

example in this code..

 

Ah yeah

will do that is none are found

 

try this

<?php
mysql_select_db('tgp') or die(mysql_error());
$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error());             
while ($row = mysql_fetch_assoc($room) ) {?>

<html>
<head>
<link href="interface design/css.css" rel="stylesheet" type="text/css">
</head>
<body class="bg">
<?php

$datein=$_POST['check-in-date'];
$dayin=$_POST['check-in-day'];
$r_type=$_POST['r_category'];
$pac=$_POST['special'];
$checkin = "$datein-$dayin" ;
$nyt=$_POST['nyts'];
$id=$_COOKIE['ID'];          

mysql_connect('localhost', 'root', 'tmc') or die(mysql_error());

mysql_select_db('tgp') or die(mysql_error());
$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error());             
while ($row = mysql_fetch_assoc($room) ) {
    $room = $row["r_no"];

//ive got error here in this line
if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')"))
{	print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
print '<b>reservation failed</b>';

print '</div>';
}	
else {
print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
 print 'Your Information has been successfully added to the database.';
print '<br><br>';
$result=mysql_insert_id();
print "Your Reservation No. is <b>$result</b>";
print '</div>';
break;
}
}

mysql_close();
?>
</body>
</html>

 

Techie out, head killing now!

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-362388
Share on other sites

<html>
<head>
<link href="interface design/css.css" rel="stylesheet" type="text/css">
</head>
<body class="bg">
<?php

         

mysql_connect('localhost', 'root', 'tmc') or die(mysql_error());


mysql_select_db('tgp') or die(mysql_error());

$datein=$_POST['check-in-date'];
$dayin=$_POST['check-in-day'];
$r_type=$_POST['r_category'];
$pac=$_POST['special'];
$checkin = "$datein-$dayin" ;
$nyt=$_POST['nyts'];
$room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'order by rand() limit 1");         
$id=$_COOKIE['ID']; 



while ($row = mysql_fetch_row($room)){
	echo $row="['r_no']";
break;
}
$r=mysql_free_result($room);
   
if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt','$r','$pac','$id')")or die(mysql_error()))
{	print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
print '<b>reservation failed</b>';
print '</div>';
}


else {
 print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">';
 print 'Your Information has been successfully added to the database.';
print '<br><br>';
$result=mysql_insert_id();
print "Your Reservation No. is <b>$result</b>";
print '</div>';

}




mysql_close();
?>
</body>
</html>

 

ok now i try dis code...

i try to echo d $r then it remove the resource id thin... it give me pure integer...

but its still give me failed reservation...

wat do u think d problem...

Link to comment
https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-362394
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.