Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

PHP variables passed to new page not showing up

I am looking after a website for someone and I have received all the files from the previous host/webmaster.

The site has an ordering system through paypal but the two variables that are required to be passed from the product page here to the ordering page are not showing up.

The URL of the ordering page appears to have the variables passed correctly as below

http://www.italian-christmas-cookies.com/orderbelow.php?p=55&service=Angel%20Reading

but they are not being shown on the ordering page

The code is shown below.

<b>Personalised
 <?
echo $service;
?></b>
</p>

<p>Price: &pound;<?
echo $p;
?></b>
</p>

So given all that I would expect it to show

Personalised Angel Reading

Price: £55

I'd appreciate any pointers from people with more experience than I have.

Thanks Glenn

UPDATE:

Thanks everyone, all the posts helped and it has given me progress, and a bit of education. I do not know how long ago the original author wrote the code so there might be archaic ways in amongst there.

Carrying on further would similar principles apply for later in the code where the form captures some user input and assigns a variable name such as $dateofbirth below and is used later in an email to the owner? In other words at the moment the date of birth and other fields are not being included in the email

<p>Date of Birth <i>(dd/mm/yyyy)</i><br /><input name="dateofbirth" value="<? echo $dateofbirth;?>" type="text" style="width: 350px;" /></p>


<p><br /><input type="hidden" name="service" value="<?
echo $service;
?>" />

<input type="hidden" name="p" value="<?
echo $p;
?>" />
<input type="submit" value="Order now" /></p>
</form>

The sending email code is here

$emailtext = "From: " . $clientname . "
";
$emailtext .= "Service ordered: " . $service . "
";
$emailtext .= "Price to pay: £" . $p . "
";
$emailtext .= "Date of birth: " . $dateofbirth . "
";
$emailtext .= "Questions:

" . $questions . "

";
$emailtext .= "Comments:

" . $comments . "

";
$emailtext .= $email;

In summary, is the code above old, archaic, unsupported and in need of modernising to make it work?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To use a GET parameter you must retrieve it from the $_GET array like this:

$_GET['service']

Remember to sanitize $_GET['service'] before displaying to prevent XSS and other possible attacks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...