PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon May 21, 2018 10:11 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu May 03, 2018 12:37 am 
Offline
Forum Newbie

Joined: Thu May 03, 2018 12:25 am
Posts: 3
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>


Top
 Profile  
 
PostPosted: Thu May 03, 2018 12:43 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13555
Location: New York, NY, US
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'] : '';
?>

_________________
(#10850)


Top
 Profile  
 
PostPosted: Fri May 04, 2018 12:27 am 
Offline
Forum Newbie

Joined: Thu May 03, 2018 12:25 am
Posts: 3
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>


Top
 Profile  
 
PostPosted: Fri May 04, 2018 5:46 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13555
Location: New York, NY, US
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)

_________________
(#10850)


Top
 Profile  
 
PostPosted: Sat May 05, 2018 1:19 pm 
Offline
Forum Newbie

Joined: Thu May 03, 2018 12:25 am
Posts: 3
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>


Top
 Profile  
 
PostPosted: Sat May 05, 2018 6:57 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13555
Location: New York, NY, US
The submit field may not be sent if the user uses the Enter key to submit the form. Instead, check $_SERVER['REQUEST_METHOD'] == 'POST'

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group