0

I need a solution of php post method, I have solution for get method.

Example:

Folder: /vaibrother


1st file source: data_get.php

<?php 

$data="nasir=90,sajib=80,masum=100,yeasin=110,mayeen=99";

$data=explode(",",$data);
for($i=0; $i<count($data); $i++){

$ns=explode("=",$data[$i]);
$name=$ns[0]; $score=$ns[1]; 

if(isset($_GET["id"]) && $_GET["id"] == $name) $output = "$name = $score";

} if(!empty($output)) echo $output; ?>

<hr>
<form action="" method="GET">

<input name="id" value="masum"> {example: nasir, sajib, masum, yeasin, mayeen}

<input type="submit" value="check">

</form>

2nd file source: data_post.php

<?php 

$data="nasir=90,sajib=80,masum=100,yeasin=110,mayeen=99";

$data=explode(",",$data);
for($i=0; $i<count($data); $i++){

$ns=explode("=",$data[$i]);
$name=$ns[0]; $score=$ns[1]; 

if(isset($_POST["id"]) && $_POST["id"] == $name) $output = "$name = $score";

} if(!empty($output)) echo $output; ?>

<hr>
<form action="" method="POST">

<input name="id" value="masum"> {example: nasir, sajib, masum, yeasin, mayeen}

<input type="submit" value="check">

</form>

3rd file source: get_success.php

This is a proxy<hr>

<?php 

$fp=fopen("http://localhost/vaibrother/data_get.php?id=mayeen","r");
echo fread($fp,99999);
fclose($fp);

?>

4th file source: post_success.php {??????}

(I need the solution of this file)

This is a proxy<hr>

<?php 

/*

http://localhost/vaibrother/data_post.php

id = mayeen

[ How to display result 99 ? ]

I Dont Know

*/

?>

2 Answers2

0

You cannot send data as POST using PHP. A workaround could be found here. Some ways include using a FORM to send POST data to a specific PHP file. Example:

<html>
<body>
    <form name="POSTFORM" method="post" action="http://localhost/vaibrother/data_post.php">
         <input type="text" name="id" value="mayeen">
         <input type="submit" value="Submit">
    </form>
</body>
</html>
Community
  • 1
  • 1
Jad
  • 76
  • 8
0

Your post method should be define like

            <div class="form-group">
                <label for="form_name">Firstname *</label>
                <input id="form_name" type="text" name="name" class="form-control" placeholder="Please enter your firstname *" required="required" data-error="Firstname is required.">
            </div>
        </div>

and then get the post value like Welcome