php - Open a hidden JavaScript form when linked from a different page -
i don't know if there answer question, i'll try explain , hope smart enough me :).
all right:
for school have website can log in , register etc. on index there log in , register form included, hidden javascript. pressing button you'll able login or register (one of forms appear). problem: i'm checking register form php on different page, , errors outputted in form on page.
but, when go register/login page, hidden, ofcourse, , input gone user , have retype everything. <? if(isset($_post['example'])){echo htmlentities ($_post['example']);} ?>
in form doesn't work anymore. putting code other page in index doesn't seem option.
thanks in advance response,
paul
edit - i'll post code make clearer. javascript hide , toggle:
'$(document).ready(function(){ $("#login").hide(); $("#registerincl").hide(); $("#loginb").click(function(){ $("#login").toggle(); $("#loginb").hide(); $("#guest").hide(); $("#registerincl").hide(); $("#register").hide(); $("#hh").hide(); }); $("#register").click(function(){ $("#registerincl").toggle(); $("#register").hide(); $("#loginb").hide(); $("#guest").hide(); $("#hh").hide(); $("hr").hide(); }); $('#guest').click(function() { window.location='guest.php'; }); });'
ofcourse link register validation page:
<form action="/register" method="post" target="">
and of php code
if (isset($_get['success']) === true && empty($_get['success']) === true) { echo 'je bent geregistreerd. ga naar je email en activeer je account!'; } else { if (empty($_post) === false && empty($errors) === true) { $register_data = array( 'username' => $_post['username'], 'joined' => $_post[$time], 'password' => $_post['password'], 'first_name' => $_post['first_name'], 'last_name' => $_post['last_name'], 'email' => $_post['email'], 'email_code' => md5($_post['username'] + microtime()) ); register_user($register_data); header('location: register.php?success'); exit(); } else if (empty($errors) === false) { //echo output_errors($errors); } <form action="/register.php" method="post"> <ul class="login"> <li> <h1>we konden je niet registreren!</h1> <?php echo output_errors($errors); } ?> </li> <li> <br><br><br><a href="index">probeer opnieuw</a> </li> </ul> </form>
you want build form without action, leaving fields are.
with jquery should add event handler form submit prevents default action proceeds grab form data , ajax php class deals registration. can handle success , error events , need returned data. link below explains how reply javascript php json data.
here sample ajax request event handler can see i'm talking above. can find nice , comprehensive tutorial here
$(function() { $(".button").click(function() { // validate , process form here }); }); $.ajax({ type: "post", url: "bin/process.php", data: datastring, success: function() { $('#contact_form').html("<div id='message'></div>"); $('#message').html("<h2>contact form submitted!</h2>") .append("<p>we in touch soon.</p>") .hide() .fadein(1500, function() { $('#message').append("<img id='checkmark' src='images/check.png' />"); }); } });
Comments
Post a Comment