I have a form input data called input.php, and the data will be process in process.php,
how can I get data after the process?
source code for form input.php
<form action="process.php" method="POST" >
<select id="selectbasic" name="time" class="input100">
<option value="not" selected>-choose-< /option>
<option value="m">Minut< /option>
<option value="s">Second< /option>
</select>
<input type="text" name="field" id="time" />
<button type="submit">Time </button>
</form>
source code for process.php
<?php if ($_SERVER["REQUEST_METHOD"] == "POST") {
$nmr = $_POST['field'];
$time = $_POST['time'];
if($time =='m'){
$nmr = $nmr*60*1000;
}else if($time =='s'){
$nmr = $nmr*1000;
} echo("<script LANGUAGE='JavaScript'> window.alert('Auto refresh was
reset!'); window.history.go(-1);</script>");
}
}?>
source code for form get_data.php
<?php include ("process.php"); ?>
<?php echo $nmr; ?>
the value from variable __$nmr__
is empty.
please help me,thanks.
From your code I think your problem is the form action
is pointing to wrong file
it should be
<form action="get_data.php" method="POST" >
<select id="selectbasic" name="time" class="input100">
<option value="not" selected>-choose-< /option>
<option value="m">Minut< /option>
<option value="s">Second< /option>
</select>
<input type="text" name="field" id="time" />
<button type="submit">Time </button>
</form>
Keep in mind this code assume that get_data.php
is in same folder as input.php
You can submit the form to itself and just use the method POST to get the value.
$var =$_POST["time"];
echo $var;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.