0

I am writing a web sign up form and related php I have installed Xampp in my computer.. I had written newindex.php like below

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>    
</head>    
<body>

<form action="signup.php" method="post" >
    <input type="text" name="first" placeholder="Firstname"><br>
    <input type="text" name="last" placeholder="Lastname"><br>
    <input type="text" name="uid" placeholder="Usernmae"><br>
    <input type="password" name="pwd" placeholder="Password"><br>
    <button type="submit">Sign Up</button>
</form>

</body>
</html>

the above code which is HTML code for my signup where there are four fields first name last name uid along with password and I used method POST

where my action is signup.php and method is post

here is my signup.php

    <?php        

    include 'dbh.php';        

    $first= $_POST['first'];
    $last= $_POST['last'];
    $uid= $_POST['uid'];
    $pwd= $_POST['pwd'];        

    echo $first."<br>";
    echo $last."<br>";
    echo $uid."<br>";
    echo $pwd."<br>"; 
?>

when I am running I m getting the following...on the browser

which is incorrect

-----current output-------------

<?php    

include 'dbh.php';    

$first=$_POST['first'];
$last=$_POST['last'];
$uid=$_POST['uid'];
$pwd=$_POST['pwd'];    

echo $first."<br>";
echo $last."<br>";
echo $uid."<br>";
echo $pwd."<br>";   

?>

the above output is wrong ,it should be the values when user insert into the form which i created earlier

how can I fix this ...

any help will be welcome

where I m going wrong ...

so is my extension correct , is there a problem in PHP installation

ArK
  • 19,864
  • 65
  • 105
  • 136

3 Answers3

0

your script has to be in the folder htdocs of xampp if you installed it in standard you can copy both files in path for example C:\Program Files (x86)\xampp\htdocs You can acces these files if you type in browser URL: http://localhost/name_of_your_file.html for example otherwise your code will not be executed

Matthias
  • 96
  • 5
0

If you open the file as file:///c:/whatever the php code will not be executed as you are bypassing the server by directly opening the php file.

You have to open the file using http://localhost/newindex.php. This way, apache will process the request and execute your php code before sending the response.

ᴄʀᴏᴢᴇᴛ
  • 2,820
  • 24
  • 42
0

I have made necessary changes. Please try below code and inform me if you will face any error.

HTML Code : -

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>
<body>

<form action="signup.php" method="post">
    <input type="text" name="first" placeholder="Firstname"><br>
    <input type="text" name="last" placeholder="Lastname"><br>
    <input type="text" name="uid" placeholder="Usernmae"><br>
    <input type="password" name="pwd" placeholder="Password"><br>
    <input type="submit" name="submit" value="Sign Up">
</form>

</body>
</html>

signup.php : -

<?php
if(isset($_POST['submit']))
{
    echo $_POST['first']."<br>";
    echo $_POST['last']."<br>";
    echo $_POST['uid']."<br>";
    echo $_POST['pwd'];
}
?>
Harsh Barach
  • 927
  • 9
  • 18