PHP Developers Network
http://forums.devnetwork.net/

phpcode error updating values into url please help
http://forums.devnetwork.net/viewtopic.php?f=1&t=147637
Page 1 of 1

Author:  harshith [ Thu May 03, 2018 12:37 am ]
Post subject:  phpcode error updating values into url please help

Below code i am using to create a text box and update those values into the url but i am unable to do it.I am getting errors please help me with it.
error-undefined variables and also unable to fetch the values into url.
Thank you.

Syntax: [ Download ] [ Hide ]
<!DOCTYPE html>
<html>
<body>
<form action="" method="post">
number:<input name="number" type="text" value="7989212020">
op:<input name="op" type="text" value="4">
amount:<input name"amount" type="number" value="100">
</form>
<?php
$number=$_REQUEST['number'];
$op=$_REQUEST['op'];
$amount=$_REQUEST['amount'];
?>
<div><a href="http://api.rechapi.com/recharge.php?format=text&token=&mobile=<?php echo $number;?>&amount=<?php echo $amount;?>&opid=<?php echo $op;?>&urid=12345"><input type="button" name="button" value="RECHARGE"></a></div>
</body>
</html>

Author:  Christopher [ Thu May 03, 2018 12:43 pm ]
Post subject:  Re: phpcode error updating values into url please help

You will get errors the first time you go to the page because the $_REQUEST array values are not set. Always check that values are set.

Also, this form is not secure. A user can pass HTML to the form to inject code into the page. Always filter and validate all input.
Syntax: [ Download ] [ Hide ]
<?php
$number= isset($_REQUEST['number']) ? $_REQUEST['number'] : '';
$op= isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
$amount= isset($_REQUEST['amount']) ? $_REQUEST['amount'] : '';
?>

Author:  harshith [ Fri May 04, 2018 12:27 am ]
Post subject:  Re: phpcode error updating values into url please help

sir ill secure the form later. After your instruction i am using the below code errors are solved but still i am unable to fetch the textfields values into the url.
<!DOCTYPE html>
<html>
<body>
<form action="" method="post">
number:<input name="number" type="text" value="">
op:<input name="op" type="text" value="">
amount:<input name"amount" type="number" value="">
</form>
<?php $number= isset($_REQUEST['number']) ? $_REQUEST['number'] : '';?>
<?php $op= isset($_REQUEST['op']) ? $_REQUEST['op'] : '';?>
<?php $amount= isset($_REQUEST['amount']) ? $_REQUEST['amount'] : '';?>
<div><a href="http://api.rechapi.com/recharge.php?format=text&token=&mobile=<?php echo $number;?>&amount=<?php echo $amount;?>&opid=<?php echo $op;?>&urid=12345"><input type="button" name="button" value="RECHARGE"></a></div>
</body>
</html>

Author:  Christopher [ Fri May 04, 2018 5:46 pm ]
Post subject:  Re: phpcode error updating values into url please help

What happens when you submit the form? You don't have an action URL or a submit button in the form. You could also wrap the code that creates the link in an if() to only show that if the form is submitted (check HTTP METHOD)

Author:  harshith [ Sat May 05, 2018 1:19 pm ]
Post subject:  Re: phpcode error updating values into url please help

sir please check the below code .my requirement is when user enters their details the details should be updated in the url and by clicking the submit button the url should be loaded.where should i place this url in the code? and i made changes to the code by your previous instruction.


url=http://api.rechapi.com/recharge.php?format=text&token=HM8JCoGEVCmGuqbfvR&mobile=<?php echo $_number;?>&amount=<?php echo $_amount;?>&opid=<?php echo $provider_id;?>&urid=12345"



<!DOCTYPE html>
<html>
<body>

<form method="post">
number:<input id="number" name="number" placeholder="10 Digits mobilenumber" type="number" >
op:<input id="op" name="op"placeholder="select an operator" type="number" >
amount:<input id="amount" name="amount"placeholder="select an operator" type="number">
<input type="button" name="submit" value="submit">
<?php
if (isset($_REQUEST['submit']))
{
$number= isset($_REQUEST['number']) ? $_REQUEST['number'] : '';
$op= isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
$amount= isset($_REQUEST['amount']) ? $_REQUEST['amount'] : '';
}
?>
</form>
</body>
</html>

Author:  Christopher [ Sat May 05, 2018 6:57 pm ]
Post subject:  Re: phpcode error updating values into url please help

The submit field may not be sent if the user uses the Enter key to submit the form. Instead, check $_SERVER['REQUEST_METHOD'] == 'POST'

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/