Hello,

I am trying to create a form like this:

registration1.php

<form name="registration1" action="registration2.php<?php //$_SERVER['PHP_SELF'] ?>" method="POST">

<tr>
    <td>First Name</td>
    <td><input style="width: 500px;" type="text" name="fname" size="80px"><br><br></td>
</tr>
<tr>
    <td>Last Name</td>
    <td><input style="width: 500px;" type="text" name="lname" size="80px"><br><br></td>
</tr>
<tr>
    <td>Email Address</td>
    <td><input style="width: 500px;" type="text" name="email" size="80px"><br><br></td>
</tr>
<tr>
    <td>Phone No</td>
    <td><input style="width: 500px;" type="text" name="phone" size="80px"><br><br></td>
</tr>
<tr>
    <td>Skype</td>
    <td><input style="width: 500px;" type="text" name="skype" size="80px"><br><br></td>
</tr>
    <td></td>
    <td><input type="checkbox" name="term" value="">I have read and understand the <a href="#">Terms & Conditions</a>
    </td>    

</table>       

<?php include('includes/setting.php'); ?>                

<div class="buttons"><a class="button" data-type="register" onClick="window.location.href = '<?php SITEURL ?>registration2.php';">register</a></div><br><br>                         
<input type="submit" class="button" name="register" value="Simpan"> <!-- onClick="window.location.href = '<?php SITEURL ?>registration2.php';"/> -->

</form>

I already add registration2.php in action and I still wonder why after I click Simpan button why the page does not change to registration2.php

The url does only moves to: http://localhost/squprime/registration1.php?fname=&lname=&email=&phone=&skype=&register=Simpan

Attribute name="submit" always for submit button. And check your HTML syntax - where starts <table> ?

commented: The name attr for submit inputs can be anything. -1

You need to change the action value of you form.

action="<?php $_SERVER['PHP_SELF']; ?>/registration2.php"

commented: <?php echo $_SERVER['HTTP_HOST']; ?>/registration2.php +0

The name attr can have any value. Does not have to be submit. @AndrisP is incorrect. name can = anything.. the type needs to = submit

Here is example for @AndrisP he is not sure about forms and php.

<form action="" method="POST" >
<input type="submit" name="anything" value="Submit" />
</form>


<?php


if(isset($_POST['anything'])){
//Process the form


}else{
//dispay somthing else.

}

If you var_dump $_POST['anything'] you will get the value of Submit.

@AndrisP

By the way, do not use $_SERVER['HTTP_HOST'] because it can be set by the client header request, it's not a value set by the server, so it can be dangerous. Bye!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.