登录 | 注册 | FAQ
Anonymous

my code is not working

+ 发表回复

2 篇帖子 分页: 1 / 1


my code is not working

omatthew » 周日 11月 06, 2016 11:06 pm

pls can anyone help me figure out why my code is not working, am try to create a simple multiplication table with php loop, and i use $_post[''] to get the what people enter from my html form. but it does not seems to work. below are my codes pls is there anything am messing?


<html>

<head>
<title>Matthew</title>


<?php

$times=2;

if(isset($_post['submit1'])) {

$start= $_post['textstart'];
$end= $_post['textend'];
$times=$_post['texttimes'];

for($start; $start<=$end; $start++) {
$answer= $start * $times;
print $start. "multiply by" . $times . "=" . $answer . "<br/>";


}
}

?>


</head>



<body>

<form name="matthewform" method= "post" action= "matthew.php">


Enter Start Number <input type ="text" name="textstart" size= "5" value="1">
Enter End Number <input type ="text" name ="textend" size= "5" value= "10">
Multiply By <input type= "text" name= "texttimes" size= "5" value= <?php print $times;?>> <br/><br/>
<input type="submit" value="Calculate" name="submit1">

</form>




</body>



</html>







have try different method in using $_post [''] to get information from what people enter in my form but non of them work form me with $_post ['']
头像

omatthew

  • 帖子: 1
  • 注册: 周日 11月 06, 2016 10:56 pm

Re: my code is not working

Farhin Qureshi » 周二 1月 24, 2017 12:21 pm

Hi,
you have made many mistakes in your code which has been corrected below:
代码: 全选
<html>

<head>
<title>Matthew</title>


<?php

$times=2;

if(isset($_post['submit1'])) {

$start= $_post['textstart'];
$end= $_post['textend'];
$times=$_post['texttimes'];

for($start; $start<=$end; $start++) {
$answer=1;
$answer= $start * $answer;
print $start. "multiply by" . $end . "=" . $answer . "<br/>";


}
}

?>


</head>



<body>

<form name="matthewform" method= "post" action= "matthew.php">


Enter Start Number <input type ="text" name="textstart" size= "5" value="1">
Enter End Number <input type ="text" name ="textend" size= "5" value= "10">
Multiply By <input type= "text" name= "texttimes" size= "5" value= <?php print $answer;?>> <br/><br/>
<input type="submit" value="Calculate" name="submit1">

</form>




</body>



</html>




头像

Farhin Qureshi

  • 帖子: 45
  • 注册: 周二 1月 03, 2017 11:33 am
--
Farhin Qureshi
.NET Developer
http://www.ifourtechnolab.com


+ 发表回复

分页: 1 / 1