Redirecting URL
Posted: Wed Feb 20, 2013 6:05 am
Hi, how can I redirect in paypal when I choose the payment option paypal after the submit button here is my code
Code: Select all
<div id="maincontent">
<div class="scroll">
<script type='text/javascript' src='http://code.jquery.com/jquery.min.js'></script>
<script type='text/javascript'>
$(function(){
$('#places, #place, #service, #timestart, #timeend, #date, #menu, #person, #full, #down, #confirm, #totalPrice, #payment').bind('keyup', function() {
if(allFilled()) $('#register').removeAttr('disabled');
});
function allFilled() {
var filled = true;
$('body input').each(function() {
if($(this).val() == '') filled = false;
});
return filled;
}
});
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?price="+str,true);
xmlhttp.send();
}
function showMenu(str)
{
if (str=="")
{
document.getElementById("txtMenu").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtMenu").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getmenu.php?foodName="+str,true);
xmlhttp.send();
}
function calculateTotal(person)
{
var price = document.getElementById("final_price").value;
var totalValue = (price * person);
var need = totalValue / 2;
var prices =document.getElementById("totalPrice");
prices.innerHTML = "Php"+totalValue;
$('#hiddenValue').val(totalValue)
//return totalValue;
var prices =document.getElementById("payment");
prices.innerHTML = "Downpayment: "+ need;
$('#hiddenvalue').val(need)
return need;
}
$("#frmEvent").submit(function(){
var totalValue = document.getElementById('totalValue');
totalValue.value = calculateTotal();
var need = document.getElementById('need');
need.value = calculateTotal(); // <-- CHANGED
});
</script>
<?php
error_reporting(0);
$submit=$_POST['submit'];
//form data
$username=$_GET['username'];
$firstn=$_GET['firstn'];
$lastn=$_GET['lastn'];
$place=$_POST['place'];
$servicePlace=$_POST['places'];
$choiceName = $_POST['menuName'];
$serviceName = $_POST['users'];
$person = $_POST['person'];
$datetime = $_POST['datetime'];
$timestart=$_POST['timestart'];
$timeend=$_POST['timeend'];
$totalPrice=$_POST['hiddenValue'];
$payment=$_POST['hiddenvalue'];
$payments=$_POST['payments'];
$confirm=$_POST['confirm'];
$pay = "";
$payit = $_POST['payit'];
if ($payit == 'Fullpayment') {
$pay = $totalPrice;
}
elseif ($payit == 'Downpayment') {
$pay = $payment;
}
if(isset($_POST['submit'])){
$connect = mysql_connect("localhost","","");
mysql_select_db("");
$namecheck= mysql_query("SELECT datetime FROM reservation WHERE datetime='$datetime'");
$count= mysql_num_rows($namecheck);
$checkname= mysql_query("SELECT firstn FROM users WHERE username = '".$_SESSION['username']."'");
$count= mysql_num_rows($checkname);
$info = mysql_fetch_array($checkname);
$fname = $info['firstn'];
$checkname= mysql_query("SELECT lastn FROM users WHERE username = '".$_SESSION['username']."'");
$count= mysql_num_rows($checkname);
$info = mysql_fetch_array($checkname);
$lname = $info['lastn'];
$checkname= mysql_query("SELECT username FROM users WHERE username = '".$_SESSION['username']."'");
$count= mysql_num_rows($checkname);
$info = mysql_fetch_array($checkname);
$user = $info['username'];
$datecheck = mysql_query("SELECT * FROM reservation WHERE datetime = '$datetime'");
$info2 = mysql_fetch_array($datecheck);
$timestart2 = $info2['timestart'];
$timeend2 = $info2['timeend'];
$today1 = date('Y') .'-'. date('m') .'-'. date('d');
$tomorrow2 = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
$today2 = date("Y-m-d", $tomorrow2);
$tomorrow3 = mktime(0,0,0,date("m"),date("d")+2,date("Y"));
$today3 = date("Y-m-d", $tomorrow3);
$tomorrow4 = mktime(0,0,0,date("m"),date("d")+3,date("Y"));
$today4 = date("Y-m-d", $tomorrow4);
$tomorrow5 = mktime(0,0,0,date("m"),date("d")+4,date("Y"));
$today5 = date("Y-m-d", $tomorrow5);
$tomorrow6= mktime(0,0,0,date("m"),date("d")+5,date("Y"));
$today6 = date("Y-m-d", $tomorrow6);
$tomorrow7 = mktime(0,0,0,date("m"),date("d")+6,date("Y"));
$today7 = date("Y-m-d", $tomorrow7);
$datenotAllowed = array($today1, $today2, $today3, $today4, $today5, $today6, $today7);
foreach($datenotAllowed as $value)
{
if($value == $datetime)
{
$DateNotAllowed2 = "This date is not available!";
}
}
if($count==3)
{
echo "<center><h3><script>alert('This date is not available!')</script></h3></center>";
}
else
{
if($place=="" )
{
echo "<center><h3><script>alert('Place field must be filled')</script></h3></center>";
}
else
{
if($servicePlace=="")
{
echo "<center><h3><script>alert('Venue field must be filled')</script></h3></center>";
}
else
{
if($serviceName=="")
{
echo "<center><h3><script>alert('Service field must be filled')</script></h3></center>";
}
else
{
if($timestart=="")
{
echo "<center><h3><script>alert('Time Start field must be filled')</script></h3></center>";
}
else
{
if($timeend=="")
{
echo "<center><h3><script>alert('Time End field must be filled')</script></h3></center>";
}
else
{
if($datetime=="")
{
echo "<center><h3><script>alert('Date field must be filled')</script></h3></center>";
}
else
{
if($choiceName=="")
{
echo "<center><h3><script>alert('Menu field must be filled')</script></h3></center>";
}
else
{
if($person=="")
{
echo "<center><h3><script>alert('Venue field must be filled')</script></h3></center>";
}
else
{
if($person >= 351 )
{
echo "<center><h3><script>alert('Minimum and Maximum range of person is 50 - 350</h3></center>";
}
else
{
if($person <= 50 )
{
echo "<center><h3><script>alert('Minimum and Maximum range of person is 50 - 350')</script></h3></center>";
}
else
{
if($timestart==$timestart2)
{
echo "<center><h3><script>alert('Time already occupied!')</script></h3></center>";
}
else
{
if($timestart<=$timestart2)
{
echo "<center<h3><script>alert('Time already occupied!')</script></h3></center>";
}
else
{
if($timestart >= $timestart2 && $timestart <= $timeend2)
{
echo"<center><h3><script>alert('Time already occupied!')</script></h3></center>";
}
else
{
if($timestart==$timeend2)
{
echo"<center><h3><script>alert('Time already occupied!')</script></h3></center>";
}
else
{
if($timestart >= $timestart2 && $timestart <= $timeend2+3)
{
echo"<center><h3><script>alert('Time already occupied!')</script></h3></center>";
}
else
{
if(isset($DateNotAllowed2))
{
echo "<center><h3><script>alert('$DateNotAllowed2')</script></h3></center>";
}
else
{
if ($confirm == 0)
{
echo "<center><h3><script>alert('Terms Need to be check!')</script></h3></center>";
}
else
{
if($payit == "") {
echo "<center><h3><script>alert('Please choose the payment!')</script></h3></center>";
}
else {
$random = rand(1234567890,0987654321);
$balance = "";
if ($payit == 'Fullpayment') {
$pay = $totalPrice;
$queryreg = mysql_query("INSERT INTO reservation VALUES ('','$random','$user','$fname','$lname','$servicePlace','$choiceName','$place','$serviceName','$person','$datetime','$timestart','$timeend','$totalPrice','$payment','','pending','$pay','$pay','$payments')");
}
elseif ($payit == 'Downpayment') {
$pay = $payment;
$balance = $totalPrice - $payment;
$queryreg = mysql_query("INSERT INTO reservation VALUES ('','$random','$user','$fname','$lname','$servicePlace','$choiceName','$place','$serviceName','$person','$datetime','$timestart','$timeend','$totalPrice','$payment','','pending','$pay','$balance','$payments')");
}
if($payments == 'bank')
{
header('Location: member.php?page=view');
}
else{
if($payments == 'paypal'){
echo'
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="xxx" />
<input type="hidden" name="item_name" value="Reservation" />
<input type="hidden" name="reservation_ number" value="1" />
<input type="hidden" name="amount" value="'.$pay.'" />
<input type="hidden" name="currency_code" value="PHP" />
<input type="hidden" name="lc" value="US" />
<input type="hidden" name="bn" value="PP-BuyNowBF" />
<input type="hidden" name="return" value="http://mekenis.com/member.php?page=view" />
<input type="hidden" name="cancel_return" value="http://mekenis.com/member.php?page=member" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="notify_url" value="http://mekenis.com/memberpage/my_ipn.php?payit='.$payit.'" />
<input type="hidden" name="custom" value="'.$random.'" />
<center><input type="image" src="https://www.paypalobjects.com/webstatic/mktg/logo/bdg_payments_by_pp_2line.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"></center>
<img alt="" border="0" src="https://www.paypalobjects.com/webstatic/mktg/logo/bdg_payments_by_pp_2line.png" width="1" height="1">
</form>';
}
else
{
die();
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
?>
<h1><center>Reservation</center></h1>
<form name='frmEvent' action='<?php $_SERVER['PHP_SELF'] ?>' method='POST'>
<table width="500" margin-bottom="0px" align="center" border = "0" cellpadding="0" bgcolor="#E6E6FA">
<tr>
<td>
<b>Place:</b>
<td>
<select name='places' id='places' value='<?php echo $servicePlace; ?>'>
<option value="">-----SELECT-----</option>
<?php
$username="";
$password="";
$db = "";
$host="localhost";
$con = mysql_connect($host,$username,$password) or die(mysql_error());
$con_db = mysql_select_db($db) or die(mysql_error());
$sel2 = mysql_query("SELECT * FROM places");
while($row2 = mysql_fetch_assoc($sel2)){
$dbService= $row2['servicePlace'];
echo"
<option value='$dbService'>$dbService</option>";
}
?>
</select>
<tr>
<td>
<b>Venue:</b>
</td>
<td>
<input id="place" type="text" name='place' value='<?php echo $place; ?>'>
</td>
</tr>
<tr>
<td>
<b>Service:</b>
<td>
<select name='users' id='service' onchange='showUser(this.value)' value='<?php echo $serviceName; ?>'>
<option value="">-----SELECT-----</option>
<?php
$username="";
$password="";
$db = "";
$host="localhost";
$con = mysql_connect($host,$username,$password) or die(mysql_error());
$con_db = mysql_select_db($db) or die(mysql_error());
$sel2 = mysql_query("SELECT * FROM service");
while($row2 = mysql_fetch_assoc($sel2)){
$dbService= $row2['serviceName'];
echo"
<option value='$dbService'>$dbService</option>";
}
?>
</select>
<div id="txtHint"></div></br>
<tr>
<td>
<b> Time start:</b><select name="timestart" id="timestart" value='<?php echo $timestart; ?>'>
<option value=""></option>
<option value="8:00">8:00</option>
<option value="9:00">9:00</option>
<option value="10:00">10:00</option>
<option value="11:00">11:00</option>
<option value="12:00">12:00</option>
<option value="13:00">13:00</option>
<option value="14:00">14:00</option>
<option value="15:00">15:00</option>
<option value="16:00">16:00</option>
<option value="17:00">17:00</option>
<option value="18:00">18:00</option>
<option value="19:00">19:00</option>
</td>
<td>
</select>
<b>Time end:</b><select name="timeend" id="timeend" value='<?php echo $timeend; ?>'>
<option value=""></option>
<option value="8:00">8:00</option>
<option value="9:00">9:00</option>
<option value="10:00">10:00</option>
<option value="11:00">11:00</option>
<option value="12:00">12:00</option>
<option value="13:00">13:00</option>
<option value="14:00">14:00</option>
<option value="15:00">15:00</option>
<option value="16:00">16:00</option>
<option value="17:00">17:00</option>
<option value="18:00">18:00</option>
<option value="19:00">19:00</option>
<option value="20:00">20:00</option>
<option value="21:00">21:00</option>
<option value="22:00">22:00</option>
<option value="23:00">23:00</option>
<option value="24:00">00:00</option>
</select>
</td>
</tr>
<tr>
<td>
<meta charset="utf-8">
<link rel = "stylesheet" type="text/css" href="calendar/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css">
<b>Date:</b>
</td>
<td>
Reservation must be 1 week or more before the event.<br>
<input id="date" type="text" name='datetime' value='<?php echo $datetime; ?>'
</td>
</tr>
<script type="text/javascript" src ="calendar/jquery-1.8.3.js"></script>
<script type="text/javascript" src ="calendar/jquery-ui-1.9.2.custom.js"></script>
<script type="text/javascript" src ="calendar/ui.js"></script>
<tr>
<td>
<b>Menu:</b>
<td>
<select name='menu' id='menu' onchange='showMenu(this.value)' value='<?php echo $choiceName; ?>'>
<option value="">-----SELECT-----</option>
<?php
$username="";
$password="";
$db = "";
$host="localhost";
$con = mysql_connect($host,$username,$password) or die(mysql_error());
$con_db = mysql_select_db($db) or die(mysql_error());
$sel2 = mysql_query("SELECT * FROM menu");
while($row2 = mysql_fetch_assoc($sel2)){
$dbService= $row2['choiceName'];
echo"
<option value='$dbService'>$dbService</option>";
}
?>
</select>
<div id="txtMenu"></div>
<tr>
<td>
<b>How Many Person/s:</b>
</td>
<td>
<input type="text" name='person' id="person" onkeydown='calculateTotal(this.value)' onkeyup='calculateTotal(this.value)'>
</td>
</tr>
<tr>
<td ></td>
</tr>
<tr>
<td>
<b>Total Price:</b>
</td>
<td>
<div id='totalPrice'>
</div>
</td>
</tr>
<tr>
<td>
<b>Downpayment:</b>
</td>
<td>
<div id='payment'>
</div>
</td>
</tr>
<tr>
<td>
<h4>Payment it in:</h4>
</td>
<td>
<input type="radio" id="full" name="payit" value="Fullpayment">Full payment
<input type="radio" id="down" name="payit" value="Downpayment">Down payment
</td>
</tr>
<tr>
<td>
<h4>Type of Payment:</h4>
</td>
<td>
<input type="radio" id="paypal" name="payments" value="paypal">Paypal
<input type="radio" id="bank" name="payments" value="bank">Bank Payment
</td>
</tr>
</table>
</br>
<center><b><h2>TERMS and Conditions</h2></b></center>
<table width="600" align="center" border = "0" cellpadding="0" bgcolor="#E6E6FA">
<td>
<ul>
<li>No refunding of payment for cancellation 2-4 days before the event.<br>
<li>Additional charges if materials or equipment is damage on the event.
<li>50% down payment upon confirmation.
<li>Left overs will be given to client provided that they bring their own containers
<li>Changing of menus or other additional subject for the event is not acceptable 4 days before the event.
<li>No excess of time, Kung anu pinareserve mo hanggang dun lang(english?)
<li>Any areas that has entrance fee shall be shouldered by the clients.
</ul>
<center>
<input type="checkbox" name="confirm" value="1" id="confirm" />
<label for="confirm">I agree with the terms</label>
</center>
</td>
</table>
<input type="hidden" name="hiddenValue" id="hiddenValue" value=''/>
<input type="hidden" name="hiddenvalue" id="hiddenvalue" value=''/>
<center><input type='submit' id='register' name='submit' value='Submit' disabled='disabled' /></center>
</form>
</div>
</div>