Web Hosting Talk







View Full Version : [PHP] Hey i need to carry some variables + add some :S


eHostBox
09-25-2004, 08:10 PM
hey everyone,
i am currently making an orders script for my website ehostbox.com and i am having a few problems with my code,

i am trying to carry the following variables in this cycle...


step_one.php (forms only)
Domain:_____________
TLD: (drop down /com/net/org/info/biz/us)
----------CARRY TO---------------------
step_two.php
Displays domain, TLD and gives another drop down
method = Transfer/Register
(this script now needs to carry $domain and $tld from step_one.php to step_three.php but also include $method into step_three.php which will then show the 3 variables and have another to be added (i can work from step_two.php when its completed)


here is what i have come up with...

STEP_ONE.PHP
<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Domain Registration Please type your domain name below and select the
applicable TLD from the drop down menu</title>
</head>

<body bgcolor="#C8E3E9" topmargin="0">

<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: solid; border-width: 2; padding: 0" bordercolor="#111111" width="640" id="AutoNumber2" bgcolor="#FFFFFF">
<tr>
<td width="100%">
<img border="0" src="images/order_head.gif" width="640" height="85"></td>
</tr>
<tr>
<td width="100%"><font face="Verdana" size="2"><b>Domain Registration<br>
</b>Please type your domain name below and select the applicable TLD from
the drop down menu.<br>
&nbsp;</font><center><form method="GET" action="step_two.php">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="57%" id="AutoNumber3">
<tr>
<td width="50%"><font face="Verdana" size="2">Domain:</font></td>
<td width="50%"><font face="Verdana" size="2">TLD:</font></td>
</tr>
<tr>
<td width="50%"><font face="Verdana">
<input type="text" name="domain" size="45"></font></td>
<td width="50%"><font face="Verdana">.<?php include("tld_select.php"); ?></font></td>
</tr>
</table>
</center>
<br>
<input type="submit" value="Check Domain" name="B1"><br>
&nbsp;</form></td>
</tr>
<tr>
<td width="100%" style="border-top-style: solid; border-top-width: 1; padding: 0" bgcolor="#F2F3E9">
<p align="center"><b><font face="Verdana" size="1">©Copyright 2004 Digi.Cart™
ALL RIGHTS RESERVED</font></b></td>
</tr>
</table></center>

</body>

</html>


STEP_TWO.PHP
<?php
$domain = $_GET['domain'];
$tld = $_GET['tld'];
$method = $_POST['method'];

print"<html>
<head>
<meta http-equiv='Content-Language' content='en-gb'>
<meta name='GENERATOR' content='Microsoft FrontPage 5.0'>
<meta name='ProgId' content='FrontPage.Editor.Document'>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>
<title>Domain Registration Please type your domain name below and select the
applicable TLD from the drop down menu</title>
</head>

<body bgcolor='#C8E3E9' topmargin='0'>

<center>
<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse; border-style: solid; border-width: 2; padding: 0' bordercolor='#111111' width='640' id='AutoNumber2' bgcolor='#FFFFFF'>
<tr>
<td width='100%'>
<img border='0' src='images/order_head.gif' width='640' height='85'></td>
</tr>
<tr>
<td width='100%'><font face='Verdana' size='2'><b>Domain Registration &amp;
Transfer<br>
</b>The domain that you entered in Step 1 has been queried by our servers,
please ensure that it<br>
is available for registration, or if you already own the domain please
select &quot;Transfer&quot; from the drop down &quot;Method&quot; box.</font><center><form method='POST' action='step_three.php?domain=$domain&method=$method&tld=$tld'>
&nbsp;<center>
<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='72%' id='AutoNumber4'>
<tr>
<td width='71%' align='left' bgcolor='#C8E3E9'><font face='Verdana' size='2'><b>Domain</b></font></td>
<td width='15%' align='left' bgcolor='#C8E3E9'><font face='Verdana' size='2'><b>
TLD</b></font></td>
<td width='18%' align='left' bgcolor='#C8E3E9'><font face='Verdana' size='2'><b>Method</b></font></td>
</tr>
<tr>";
echo"<td width='71%' align='left'><font face='Verdana' size='2'>$domain</font>";
print"</td>";
echo"<td width='15%' align='left'><font face='Verdana' size='2'>$tld</font>";
print"</td>";
print"<td width='18%' align='left'><font face='Verdana'>";
echo"<select size='1' name='method'>
<option selected value='Register'>Register</option>
<option value='Transfer'>Transfer</option>
</select>";
print"</font></td>
</tr>
</table></center>
<p>
<input type='submit' value='Order Domain' name='B1'><br>
&nbsp;</p>
</form></td>
</tr>
<tr>
<td width='100%' style='border-top-style: solid; border-top-width: 1; padding: 0' bgcolor='#F2F3E9'>
<p align='center'><b><font face='Verdana' size='1'>©Copyright 2004 Digi.Cart™
ALL RIGHTS RESERVED</font></b></td>
</tr>
</table></center>

</body>

</html>";
?>

if someone could copy my code and place the working code into it that would be great. ill give you a 50% off coupon for eHostBox.com in return for your help.

P.S. the "TLD_SELECT.PHP" is just a dropdown menu that selects the TLD's from a MySQL Database.

sea otter
09-25-2004, 10:48 PM
ok, here's a start (multiple posts follow), step_one.php

I changed a couple of things:

1. submit method is now post instead of get
2. the input button value of "Check Domain" is no good; no spaces! It's now "CheckDomain"


<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Domain Registration Please type your domain name below and select the
applicable TLD from the drop down menu</title>
</head>

<body bgcolor="#C8E3E9" topmargin="0">

<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: solid; border-width: 2; padding: 0" bordercolor="#111111" width="640" id="AutoNumber2" bgcolor="#FFFFFF">
__<tr>
____<td width="100%">
____<img border="0" src="images/order_head.gif" width="640" height="85"></td>
__</tr>
__<tr>
____<td width="100%"><font face="Verdana" size="2"><b>Domain Registration<br>
____</b>Please type your domain name below and select the applicable TLD from
____the drop down menu.<br>
&nbsp;</font><center><form method="post" action="step_two.php">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="57%" id="AutoNumber3">
__<tr>
____<td width="50%"><font face="Verdana" size="2">Domain:</font></td>
____<td width="50%"><font face="Verdana" size="2">TLD:</font></td>
__</tr>
__<tr>
____<td width="50%"><font face="Verdana">
______<input type="text" name="domain" size="45"></font></td>
____<td width="50%"><font face="Verdana">.

<?php include("tld_select.php"); ?></font></td>
__</tr>
</table>
</center>
__<br>
__<input type="submit" value="CheckDomain" name="B1"><br>
&nbsp;</form></td>
__</tr>
__<tr>
____<td width="100%" style="border-top-style: solid; border-top-width: 1; padding: 0" bgcolor="#F2F3E9">
____<p align="center"><b><font face="Verdana" size="1">©Copyright 2004 Digi.Cart™
____ALL RIGHTS RESERVED</font></b></td>
__</tr>
</table></center>

</body>

</html>

sea otter
09-25-2004, 10:53 PM
ok, here's step_two.php

Couple of small changes:

1. converted the page to mostly html with php printing/processing in only a couple of places.
2. removed $_POST['method'] as it was not needed on this page
3. converted $_GETs to $_POSTs to comply with changes to step_one.php
4. changed input button value from "Input Domain" to "InputDomain" (space issue again)

Both forms work for me (in that they come up and the values propagate and display correctly).


<html>
<head>
<meta http-equiv='Content-Language' content='en-gb'>
<meta name='GENERATOR' content='Microsoft FrontPage 5.0'>
<meta name='ProgId' content='FrontPage.Editor.Document'>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>
<title>Domain Registration Please type your domain name below and select the
applicable TLD from the drop down menu</title>
</head>

<?php
$domain = $_POST['domain'];
$tld = $_POST['tld'];
?>

<body bgcolor='#C8E3E9' topmargin='0'>
<center>
<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse; border-style: solid; border-width: 2; padding: 0' bordercolor='#111111' width='640' id='AutoNumber2' bgcolor='#FFFFFF'>
__<tr>
____<td width='100%'>
____<img border='0' src='images/order_head.gif' width='640' height='85'></td>
__</tr>
__<tr>
____<td width='100%'><font face='Verdana' size='2'><b>Domain Registration &
____Transfer<br>
____</b>The domain that you entered in Step 1 has been queried by our servers,
____please ensure that it<br>
____is available for registration, or if you already own the domain please
____select &quot;Transfer&quot; from the drop down &quot;Method&quot; box.</font><center><form method='post' action='step_three.php?domain=$domain&method=$method&tld=$tld'>
&nbsp;<center>
<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='72%' id='AutoNumber4'>
__<tr>
____<td width='71%' align='left' bgcolor='#C8E3E9'><font face='Verdana' size='2'><b>Domain</b></font></td>
____<td width='15%' align='left' bgcolor='#C8E3E9'><font face='Verdana' size='2'><b>
____TLD</b></font></td>
____<td width='18%' align='left' bgcolor='#C8E3E9'><font face='Verdana' size='2'><b>Method</b></font></td>
__</tr>
__<tr>
<? print "<td width='71%' align='left'><font face='Verdana' size='2'>$domain</font></td>"; ?>
<? print "<td width='15%' align='left'><font face='Verdana' size='2'>$tld</font></td>"; ?>
<td width='18%' align='left'><font face='Verdana'>
<select size='1' name='method'>
____<option selected value='Register'>Register</option>
____<option value='Transfer'>Transfer</option>
</select>
</font></td>
__</tr>
</table></center>
<p>
__<input type='submit' value='OrderDomain' name='B1'><br>
&nbsp;</p>
____</form></td>
__</tr>
__<tr>
____<td width='100%' style='border-top-style: solid; border-top-width: 1; padding: 0' bgcolor='#F2F3E9'>
____<p align='center'><b><font face='Verdana' size='1'>©Copyright 2004 Digi.Cart™
____ALL RIGHTS RESERVED</font></b></td>
__</tr>
</table></center>

</body>
</html>

Burhan
09-26-2004, 01:58 AM
Learn how to use sessions (http://www.php.net/sessions) and this problem can be solved very easily

eHostBox
09-26-2004, 06:55 AM
indeed it could fyrestrtr: but i am building it simple so its easy to customise,

and sea_otter: thanks mate,

if you need to use it www.ehostbox.com coupon code = "seaotters50off" if not pass it on if you wish,

thanks for your help.

ALSO...
[quote]
step_two.php doesnt work, it isnt posting the correct variables into the URL to step 3 it is just sending...

"step_three.php?domain=$domain&tld=$tld&method=$method"
where it should be replacing the variables.

sea otter
09-26-2004, 11:37 AM
Originally posted by eHostBox
indeed it could fyrestrtr: but i am building it simple so its easy to customise,

and sea_otter: thanks mate,

if you need to use it www.ehostbox.com coupon code = "seaotters50off" if not pass it on if you wish,

thanks for your help.

ALSO...
[quote]
step_two.php doesnt work, it isnt posting the correct variables into the URL to step 3 it is just sending...

"step_three.php?domain=$domain&tld=$tld&method=$method"
where it should be replacing the variables.

:) I like the coupon code! I'll go check out youre site.

fyrestrtr's right; sessions make the whole issue of propagating values, handling the "back" button and dealing with missing/incorrect values a snap. Ultimately, it's the way to go. It also helps you avoid displaying info in the url and having people mess with the values there.

sea otter
09-26-2004, 11:39 AM
doh! :homer: forgot to mention in the last post how to fix the problem in step_two.

I forgot the surround that line of code with a <? print "..........."; ?> statement. At the moment it isn't being evaluated by PHP, so the variables aren't being set. This will fix the problem.

eHostBox
09-26-2004, 07:33 PM
sorry sea_otter i am a little wired at this problem at the moment, i dont quite understand where i need to add the php tags and the print statement, if you can help me out by putting them in for me it would be a huge help. Thanks, and also np about the coupon if you need any good deals with hosting/resellers or teamspeak ill give you some good ones as you have just scratched my back ill scratch yours in return,

gimme a buzz if you ever need anything bro.

sea otter
09-26-2004, 10:28 PM
Here ya go. Same code I posted last time, but with the fix in. I'm glad I saved the original files!

(and thanks for the offers :) )


<html>
<head>
<meta http-equiv='Content-Language' content='en-gb'>
<meta name='GENERATOR' content='Microsoft FrontPage 5.0'>
<meta name='ProgId' content='FrontPage.Editor.Document'>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>
<title>Domain Registration Please type your domain name below and select the
applicable TLD from the drop down menu</title>
</head>

<?php
$domain = $_POST['domain'];
$tld = $_POST['tld'];
?>

<body bgcolor='#C8E3E9' topmargin='0'>
<center>
<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse; border-style: solid; border-width: 2; padding: 0' bordercolor='#111111' width='640' id='AutoNumber2' bgcolor='#FFFFFF'>
__<tr>
____<td width='100%'>
____<img border='0' src='images/order_head.gif' width='640' height='85'></td>
__</tr>
__<tr>
____<td width='100%'><font face='Verdana' size='2'><b>Domain Registration &
____Transfer<br>
____</b>The domain that you entered in Step 1 has been queried by our servers,
____please ensure that it<br>
____is available for registration, or if you already own the domain please
____select &quot;Transfer&quot; from the drop down &quot;Method&quot; box.</font><center>
<? print "<form method='post' action='step_three.php?domain=$domain&method=$method&tld=$tld'> &nbsp;<center>"; ?>
<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='72%' id='AutoNumber4'>
__<tr>
____<td width='71%' align='left' bgcolor='#C8E3E9'><font face='Verdana' size='2'><b>Domain</b></font></td>
____<td width='15%' align='left' bgcolor='#C8E3E9'><font face='Verdana' size='2'><b>
____TLD</b></font></td>
____<td width='18%' align='left' bgcolor='#C8E3E9'><font face='Verdana' size='2'><b>Method</b></font></td>
__</tr>
__<tr>
<? print "<td width='71%' align='left'><font face='Verdana' size='2'>$domain</font></td>"; ?>
<? print "<td width='15%' align='left'><font face='Verdana' size='2'>$tld</font></td>"; ?>
<td width='18%' align='left'><font face='Verdana'>
<select size='1' name='method'>
____<option selected value='Register'>Register</option>
____<option value='Transfer'>Transfer</option>
</select>
</font></td>
__</tr>
</table></center>
<p>
__<input type='submit' value='OrderDomain' name='B1'><br>
&nbsp;</p>
____</form></td>
__</tr>
__<tr>
____<td width='100%' style='border-top-style: solid; border-top-width: 1; padding: 0' bgcolor='#F2F3E9'>
____<p align='center'><b><font face='Verdana' size='1'>©Copyright 2004 Digi.Cart™
____ALL RIGHTS RESERVED</font></b></td>
__</tr>
</table></center>

</body>
</html>

sea otter
09-26-2004, 10:31 PM
Also, I realized that you'll need to set the PHP variable "$method" somewhere on page_two.php, just as you set "$tld" on page_one.php with some included PHP code.

I assume you've got that covered, because right now it shows up as blank.

Let me know if I can help.

eHostBox
09-26-2004, 11:16 PM
okay thanks sea_otter heres what that script gives off...

http://127.0.0.1/step_three.php?domain=wheteverdomain&method=&tld=com

(thats in the url)

it doesnt post the variable for "method="
i am currently looking for some coders to help me complete the "Digi.Cart" project, there WILL be financial rewards when it is finished and is being marketed, if you think you can help and wait for payment then please contact me using my details below 2-5 coders needed to complete quickly.

eHostBox
09-27-2004, 12:11 AM
hey thanks for all your help guys especially sea_otter but dont bother doing anymore i took that other guys advice, i started to learn sessions there a million times easyer than i ever imagined and there working perfect for me now so thanks anyways but i fixed it myself,

ALSO,
the offer is still available tho because you did try.