Miguel
Miguel

Reputation: 87

Problems Submit Button

I'm new to web programing. I'm trying to learn PHP and HTML. I created an Home Page (index.html) with a navigation bar. I put there an href to a form called register_form.php, it goes to the page but after I type all the information and click in the register button, it goes to the source page. I tried to find some answers, searching, but i can't solve the problem. I use a program to send my files and have PHP, it is XAMP. I activated all modules expcept tomcat, because i'm not able.

Register_form.php

<HEAD>
<link rel="stylesheet" type="text/css" a href="web_style.css"/>
</HEAD>

<div class="caixas">
    <form action="register.php" method="POST">
    First Name: <input type="text" name="name" /><br/>
    Last Name: <input type="text" name="lname" /><br/>
    Username: <input type="text" name="uname" /><br/>
    Email: </br><input type="text" name="email1" /><br/>
    Confirm Email: <input type="text" name="email2" /><br/>
    Password: <input type="password" name="pass1" /><br/>
    Confirm Password: <input type="password" name="pass2" /><br/>
    <div class="regbut">
        <input class="reg" type="submit" value="Register" name="submit" />
    </div>
    </form>
</div>

register.php

<?PHP
require('config.php');

$erro = '<script type="text/javascript">alert("Sorry, your passwords do not match.");</script>';

if(isset($_POST['submit'])){

//Verificacao
$email1=$_POST['email1'];
$email2=$_POST['email2'];
$pass1=$_POST['pass1'];
$pass2=$_POST['pass2'];

if($email1==$email2){
    if($pass1==$pass2){
        //Continuar

        $name=mysql_escape_string($_POST['name']);
        $lname=mysql_escape_string($_POST['lname']);
        $uname=mysql_escape_string($_POST['uname']);
        $email1=mysql_escape_string($_POST['email1']);
        $email1=mysql_escape_string($email1);
        $email2=mysql_escape_string($email2);
        $pass1=mysql_escape_string($pass1);
        $pass2=mysql_escape_string($pass2);



        mysql_query("INSERT INTO login_data (name, lname, uname, email, pass) VALUES ('".$name."','".$lname."','".$uname."','".$email1."','".$pass1."')");
        header("Location: index.html");
    }else{

        echo $erro;

        exit();
    }
}else{
    echo 'Sorry, your emails do not match. </br>';
}}
?>

If you need more information please tell me. Thanks in advance

Upvotes: 0

Views: 80

Answers (1)

Almis
Almis

Reputation: 3819

The only problem that can imagine is that your web pages are not inside c:\xampp\htdocs\ or you not running your pages from localhost.

So move your files there (if they are not there) and run from localhost (if you not running your webpages from there). Your url should be like this localhost/path/to/register_form.php and not like this file:///C:/xampp/htdocs/path/to/register_form.php

Upvotes: 1

Related Questions