Web Hosting Talk







View Full Version : PHP question


MarvinH
03-10-2006, 11:21 PM
Hello,

Im not very skilled using php, I only know enough to edit codes and maybe combine one with another. In the following code, at the very bottom regardless if the user chooses paypal or another option as the $payment, it will always bring the user to money_order.php now i know im missing some { down there and i've tried placing them where i thought they should be but i've always gotten errors. I would GREATLY appriciate it if someone could help me out with this.

<?PHP
if ( $_GET["act"] == "submit" )
{
mysql_connect( "localhost", "", "" ) or die( mysql_error());
mysql_select_db( "mxchost_billing" ) or die( mysql_error() );
$date = date("y/m/d");
$name = $_POST['name'];
$payment = $_POST['payment'];
$domain = $_POST['domain'];
$email = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$country = $_POST['country'];
$postalcode = $_POST['postalcode'];
$phone = $_POST['phone'];
$username = $_POST['username'];
$password = $_POST['password'];
$paypaladdy = $_POST['paypaladdy'];
$si = $_POST['si'];
$query = "INSERT INTO accounts (name,payment,domain,price,plan,email,address,city,state,country,postalcode,phone,registered,due,username,password,paypaladdy,si)
values ('$name','$payment','$domain','$3.25','Basic','$email','$address','$city','$state','$country','$postalcode','$phone','$date','00/00/00','$username','$password','$paypaladdy','$si')";
mysql_query($query) or die (mysql_error());

if($payment == 'paypal')
header('location: paypal.php');
else
header('location: money_order.php');
}
?>

Dan L
03-10-2006, 11:27 PM
if($payment == 'paypal') {
header('location: paypal.php');
} else {
header('location: money_order.php');
}

Also, please please please read http://php.net/mysql_real_escape_string

MarvinH
03-10-2006, 11:29 PM
I've actually tried that way and i recieve the following error:

Parse error: parse error, unexpected $ in /home/mxchost/public_html/new/order_b.php on line 226

but line 226 is the end of the page which contains no php

Dan L
03-11-2006, 12:06 AM
Add one more } at the end of the page.

MarvinH
03-11-2006, 12:07 AM
lol yea i just figured that out but thanks anyways !

MarvinH
03-11-2006, 12:26 AM
I thought the probelem was solved but it's still doign the same thing lol now i have this at the end of the code:


if($payment == 'paypal') {
header('location: http://www.yahoo.ca');
} else {
header('location: http://www.msn.com');
}
}
?>

zoid
03-11-2006, 06:07 AM
The braces do not make a difference in your case, so just leave them out.

Can you post the HTML of the form posting to this code?

MarvinH
03-11-2006, 09:09 AM
<form name="order" method="post" action="order_b.php?act=submit" submit"onsubmit="return orderCheck(this);">



<table>
<tr>

<td> * Denotes required fields.
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="34%">Package</td>
<td width="66%"><input type="text" disabled="true" value="Basic"></td>
</tr>

<tr>
<td width="34%">*Domain:</td>
<td width="66%"><input name="domain" type="text"></td>
</tr>
<tr>

<td width="34%">*Name:</td>

<td width="66%"> <input name="name" type="text"></td>
</tr>
<tr>
<td>Address:</td>
<td><input name="address" type="text"></td>
</tr>
<tr>
<td>City:</td>
<td><input name="city" type="text"></td>
</tr>
<tr>
<td>State/Province</td>
<td><input name="state" type="text"></td>
</tr>
<tr>
<td>Country:</td>
<td><input name="country" type="text"></td>
</tr>
<tr>
<td>Postal Code:</td>
<td><input name="postalcode" type="text"></td>
</tr>
<tr>

<td>*Email Address:</td>
<td><input name="email" type="text"></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input name="phone" type="text"></td>
</tr>
<tr>

<td>*Choose a Username:</td>
<td><input name="username" maxlength="7" type="text"></td>
</tr>
<tr>

<td>*Choose a Password:</td>
<td><input name="password" type="text"></td>
</tr>
<tr>
<td>How did you hear about us?</td>
<td><input name="howdidyou" type="text"></td>
</tr>
<tr>
<td>Special Instructions:</td>
<td> <textarea name="si" cols="35" rows="5"></textarea>
</td>
</tr>
<tr>

<tr>

<td>Method of Payment:</td>
<td>
<select name="payment" onchange="ShowTB(this,'paypaladdy');" >
<option>Select..</option>
<option id="paypal">Paypal</option>
<option id="moneyorder">Money Order</option>
</select></td>
</tr>



<td>&nbsp;</td>
<td>


<input name="paypaladdy" style="visibility:hidden;" value="Paypal email address" size="30" >



</td>
</tr>
<tr>
<td></td>
<td>
<br> <input name="Submit" type="submit" class="button" value="Continue &gt;&gt;">
</td>
</tr>
</table></td>
</tr>
</table></form>

zeeshannaqvi
03-11-2006, 11:25 AM
Please replace this listbox html

<select name="payment" onchange="ShowTB(this,'paypaladdy');" >
<option>Select..</option>
<option id="paypal">Paypal</option>
<option id="moneyorder">Money Order</option>

with this one

<select name="payment" onchange="ShowTB(this,'paypaladdy');" >
<option>Select..</option>
<option value="paypal" id="paypal">Paypal</option>
<option value="moneyorder" id="moneyorder">Money Order</option>

The php code seems to be fine.

MarvinH
03-11-2006, 11:28 AM
Your a life saver, thank you soo much!