0

I'm trying to get the data from my HTML form and store it in a database. But everytime I submit it, it only shows me the code I inputted in the PHP not the output.

HTML code:

<form action="testing.php" method="POST" >
 <tr>
 <td> Student No. </td>
 <td class="info"> <input class="input" type="text" name="Number"/> </td>             </br>
</tr>
<tr>
<td> Password: </td>
<td class="info"> <input class="input" type="password" name="Password"/>    </td>  
</tr>
<tr>
 <td class="submit"><Input type="submit" value="Sign In"/></td>
</tr>   
</form>

PHP Code:

<?php
 $comments=""; if(isset($_POST["Number"])) { $comments = $_POST["Number"]; }
$checker=""; if(isset($_POST["Password"])) { $comments = $_POST["Password"];      }
?>
jasonlam604
  • 1,456
  • 2
  • 16
  • 25
user5207499
  • 107
  • 1
  • 1
  • 6
  • You mean that `PHP` displays when you submit the form? If `Number` is set and `Password` is set you would be overwritting `Number`. You probably want `$checker = $_POST["Password"];`.. – chris85 Jan 16 '16 at 14:34
  • Ya. The actual code shows up. Not the output – user5207499 Jan 16 '16 at 14:35
  • Do you have PHP installed? Your URL is `http://something/testing.php`, after the form submission? – chris85 Jan 16 '16 at 14:36
  • I store the php and html file on C:\xampp\htdocs.I use xampp – user5207499 Jan 16 '16 at 14:38
  • Do you have other PHP files that execute there? – chris85 Jan 16 '16 at 14:40
  • when you start xampp does the apache and sql go green to say they have started and do they have a pid. in the address bar you type `localhost/myform.php` if the form ws called myform.php and is directly in htdocs – Billy Jan 16 '16 at 14:41
  • 1
    I think. The php file is working if i put http://localhost/testing.php on the browser. When I submit the form it directs me to file:///C:/xampp/htdocs/testing.php – user5207499 Jan 16 '16 at 14:41
  • `file:///C:/xampp/htdocs/testing.php` is incorrect it should be `http://localhost/testing.php`. – chris85 Jan 16 '16 at 14:44
  • Ooohhh.. its alright now. I changed it into action="http://localhost/testing.php" – user5207499 Jan 16 '16 at 14:47

0 Answers0