Login | Register | FAQ
Anonymous

url Passing special problem i need helps thanks

+ Post a reply

Page 1 of 1


url Passing special problem i need helps thanks

by healer25 » Mon May 28, 2012 3:07 pm

This is what I'M trying to do I trying to pass a number say one "1" through url. Then use that passed variable to called forth other activities(defined variables).
Like this

the link through which the variable are passed

<html>
<head><title>passing through url</title>
</head>
<body>

<?php

echo "<a href='intourl.php?favmovie=2'>";//2 is the variable i am parsing
echo "Click here to see information about my favorite movie!";
echo "</a>";

?>
</body>
</html>

where the variable is passed to

<html>
<head>
<title>My Movie site - <?php echo $_REQUEST['favmovie']; ?></title>
</head>
<body>
<?php
echo "MY Favorite movie is ";
echo $_REQUEST['favmovie'];
echo "<br>";

?>
<?php echo "<img src ='dynamicbook1.gif'>";
?>
<br/>
<?php
$movierate2 = Stop smoking;
$movierate3 = Stop shouting;
echo "My movie rating for this movie is: ";
echo $movierate. $_REQUEST['favmovie'] .;//This is where the error is
//what I want is a situation whereby what echos Stoping
//smoking and when I pass 3 Stop shouting echos
?>
</body>
</html>

Thanks alot love all expecting Ideas
User avatar

healer25

  • Posts: 57
  • Joined: Fri Dec 17, 2010 10:16 am

Re: url Passing special problem i need helps thanks

by XainPro » Tue May 29, 2012 9:10 am

You can use Control Structure (if,else) to make this happen
see below
<?php
$movierate2 = 'Stop smoking';
$movierate3 = 'Stop shouting';
echo "My movie rating for this movie is: ";
if($_REQUEST['favmovie'] == 2) {
echo $movierate2;
}
else if($_REQUEST['favmovie'] == 3) {
echo $movierate3;

}
?>
User avatar

XainPro

  • Posts: 3327
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: url Passing special problem i need helps thanks

by healer25 » Tue May 29, 2012 10:02 am

Thanks I really appreciate but I would prefer a solution referring to parsing through url to get this done, Since desire audience would be clicking through to page as per they click on a link. However, I have another problem

This is what I'M trying to
Step 1: A form would be submitted
Step 2: I want to perform a calculation with the contents
of the form and a return statement with the value
I would have loved the contents of the form in function then return the value.

Example:
THE FORM

<form action="order.php" method="POST">
<table>
<tr>
<td>
<?php echo "You purchasing item";
echo '<input name='itemnum' value= ' . $_REQUEST['favmovie'] . '>';
?>
</td>
</tr>
<tr>
<td>Select your desired Quantity:</td>
</tr>
<tr>
<td>
<select name="qty">
<option value="" selected>Kindly Select Quantity...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>

</select>
</td>
</tr>
<tr>
<td><input type="Submit" name="Place Order" value="Place Order"></td>
</tr>
</table>
</form>


THE SCRIPT

<?php
session_start();
$_SERVER['REQUEST_METHOD'] == "POST";
?>
<html>
<head>
<title> Order Page </title>
</head>
<body>
<?php
$itemnum = ' . $_REQUEST[itemnum] . ';//This is I believe this errors are
$qty = '. $_REQUEST[qty] .'; //This is I believe this errors are
$P1 = 10;
function multiQty(){$qty * $p1 * $itemnum = $qty;//this is function I want to use them inside.
echo $qty;
echo "dollars";};
multiQty($qty);


?>
</body>
</html>


Thanks and God bless
User avatar

healer25

  • Posts: 57
  • Joined: Fri Dec 17, 2010 10:16 am

Re: url Passing special problem i need helps thanks

by XainPro » Wed May 30, 2012 11:42 am

THE SCRIPT SHOULD BE

Code: Select all
<?php
session_start();
?>
<html>
<head>
<title> Order Page </title>
</head>
<body>
<?php
$itemnum = [b]$_POST[itemnum][/b];
$qty = [b]$_POST[qty][/b];
$P1 = 10;
function multiQty(){
global $itemnum,$qty,$P1;
$the$qty =  $qty * $p1 * $itemnum;
echo $the$qty . "dollars";
}
multiQty($qty);
?>
</body>
</html>


I modified your code hope this will help :)
User avatar

XainPro

  • Posts: 3327
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1