One of the things that amazed me is the creativity in programming..!!
Whatever someone take you on, you can come up with better idea, how? Here is a question, how can I use two submit buttons on my form to be processed with php.
Simple! I will go straight to the answer...!!
Assuming your form looks like this,
Whatever someone take you on, you can come up with better idea, how? Here is a question, how can I use two submit buttons on my form to be processed with php.
Simple! I will go straight to the answer...!!
Assuming your form looks like this,
<form action="register.php" method="post" class="login_form">
<div class="login_form_input_container">
<label for="email" class="login_form_label">Email</label>
<input type="email" id="email" name="email" class="login_form_input">
</div>
<div class="login_form_input_container">
<label for="password" class="login_form_label">Password</label>
<input type="password" id="password" name="password" class="login_form_input">
</div>
<a href="forgot_password/" class="forgot_password_link">Forgot password?</a>
<input type="submit" id="login_submit" name="login_submit" value="Log In" class="login_form_submit">
<input type="submit" id="register_submit" name="register_submit" value="Register" class="login_form_submit">
</form>
As we can see, it contains two form submit buttons;
Then on your php, why can't you just have
<?php
if (isset($_POST['login_submit'])) {
require 'login.php';
} elseif (isset($_POST['register_submit'])) {
require 'register.php';
}
?>
The first form submit button will use the if statement and the second form submit
can now use the elseif block of code.
oOch..!! We just solve an headache with 5 lines of code..
Subscribe to the blog to get more from me
No comments:
Post a Comment