Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I'm learning AngularJS. And in the course i take they have an AngularJS site up and running and now i'm gonna make a registration form.

I make the form (Bootstrap form) Nothing fancy.

And at the top of the form i set: <form method="POST" action="">

Action is empty because my php script is at the top of the same file.

The problem here is that when i fill in the information in the form and press submit nothing happends. When i set the php code in another file and set Action="" to that file, then it works.

But i'm gonna try to use Remembering form data with the PHP in the same file, but that wont work if it takes me to a different site via Actions.

ANy suggestions on how i can get the form to accept the PHP in the same file?

I have tried without Action, empty action, action="." as someone said could work, but didnt.

All information is appriciated.

Thanks!

<div class="container registration_form">
<form method="POST" action="inc/registration.php">
<h1 class="text-center page-header">Registrer bruker  <span class="glyphicon glyphicon-user" style="color: orange; font-size: 30px;"></span></h1>
    <div class="form-group">
        <span class="glyphicon glyphicon-info-sign" style="color: orange; font-size: 16px;"></span> <label for="firstname">Fornavn: </label> 
        <input type="text" name="firstname" class="form-control" id="firstname" value="<?php if(isset($firstname) & !empty($firstname)) { echo $firstname; } ?>" required>
    </div>
    <div class="form-group">
        <span class="glyphicon glyphicon-info-sign" style="color: orange; font-size: 16px;"></span> <label for="lastname">Etternavn: </label>
        <input type="text" name="lastname" class="form-control" id="lastname" value="<?php if(isset($lastname) & !empty($lastname)) { echo $lastname; } ?>" required>
    </div>
    <div class="form-group">
        <span class="glyphicon glyphicon-info-sign" style="color: orange; font-size: 16px;"></span> <label for="username">Brukernavn: </label>
        <input type="text" name="username" class="form-control" id="username" value="<?php if(isset($username) & !empty($username)) { echo $username; } ?>" required>
    </div>
    <div class="form-group">
        <span class="glyphicon glyphicon-info-sign" style="color: orange; font-size: 16px;"></span> <label for="email">E-post: </label> 
        <input type="email" name="email" class="form-control" id="email" value="<?php if(isset($email) & !empty($email)) { echo $email; } ?>" required>
    </div>
    <div class="form-group">
        <span class="glyphicon glyphicon-info-sign" style="color: orange; font-size: 16px;"></span> <label for="password">Passord: </label> 
        <input type="password" name="password" class="form-control" id="password" required>
    </div>
    <button type="submit" class="btn btn-success btn-lg btn-block">Registrer</button>
</form>
<br>
<p>Allerede registrert? <a href="#">Trykk her for å logge inn!</a> <span class="glyphicon glyphicon-lock" style="color: orange; font-size: 20px;"></span></p>

    <?php  

require_once('../config/connect.php');
if (isset($_POST) & !empty($_POST)) {
    $firstname = mysqli_real_escape_string($connection, $_POST['firstname']);
    $lastname = mysqli_real_escape_string($connection, $_POST['lastname']);
    $username = mysqli_real_escape_string($connection, $_POST['username']);
    $email = mysqli_real_escape_string($connection, $_POST['email']);
    $password = md5($_POST['password']);
    $sql = "INSERT INTO `user` (firstname, lastname, username, email, password) VALUES ('$firstname', '$lastname', '$username', '$email', '$password')";
    $result = mysqli_query($connection, $sql);
    if ($result) {
        header("location: ../#/welcome");
    } else {
        echo "Registrering mislykket";
    }
}

?>
share|improve this question
1  
do you have code to show us? – tylerlindell 20 hours ago
    
Code in post above. – Joakim 3 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.