Lesh0 Member
![Member Member](https://2img.net/h/i654.photobucket.com/albums/uu265/hoover78/User%20ranks/member.png)
![Lesh0](https://2img.net/h/i654.photobucket.com/albums/uu265/hoover78/adds/no_avatar.gif)
Posts : 5 Join date : 2011-04-18
![Ajax/jQuery Form $_POST and use PHP? Empty](https://2img.net/i/fa/empty.gif) | Subject: Ajax/jQuery Form $_POST and use PHP? Wed May 11, 2011 10:00 pm | |
| Okay... so I have used jQuery to show and hide my DIVs but I was wondering if there is any way to sumbit a form (a registration form) without loading the whole page so that it doesn't go back to the default div (not hidden by default). - Code:
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title><?php $LOL="Untitled." ; echo "$LOL"; ?></title> <link rel="stylesheet" href="style/css.css " type="text/css" media="screen" title="" charset="utf-8" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("a#hide").click(function(){ $(".test").hide(1000);
$(".test1").show(1000); }); }); </script> </head> <body> <table width="100%;" style="height:auto;"> <tr> <td valign="top" width="75%"style="padding:15px; margin:100% auto; text-align:right; vertical-align:text-top;"> <h2 valign="middle">the<strong>Untitled</strong>site</h2> </td> <td id="wrapper" width="25%" height="100%" style="margin-left:10px;"> <div class="test1" style="display:none;"> <?php include('reg2.php')?> </div> <div class="test"> <?php include('login1.php')?> </div> </td> </tr> </table> <div id="footer"> Designed and Coded by <strong>kenshn111</strong> </div> </body> </html>
register form: - Code:
-
<?php
error_reporting (E_ALL ^ E_NOTICE);
?> <?php
if ( $_POST['registerbtn'] ){ $getuser = $_POST['user']; $getemail = $_POST['email']; $getpass = $_POST['pass']; $getretypepass = $_POST['retypepass']; if ($getuser){ if ($getemail){ if ($getpass){ if ($getretypepass){ if ( $getpass === $getretypepass ){ if ( (strlen($getemail) >= 7) && (strstr($getemail, "@")) && (strstr($getemail, ".")) ){ require("./connect.php"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $query = mysql_query("SELECT * FROM users WHERE email='$getemail'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $password = md5(md5("kjfiufj".$password."Fj56fj")); $date = date("F d, Y"); $code = md5(rand()); mysql_query("INSERT INTO users VALUES ( '', '$getuser', '$password', '$getemail', '0', '$code', '$date' )"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $site = "http://localhost/tutorials/Member System"; $webmaster = "nickfrosty <admin@nickfrosty.com>"; $headers = "From: $webmaster"; $subject = "Activate Your Account"; $message = "Thanks for registering. Click the link below to activate your account.\n"; $message .= "$site/activate.php?user=$getuser&code=$code\n"; $message .= "You must activate your account to login."; if ( mail($getemail, $subject, $message, $headers) ){ $errormsg = "You have been registered. You must activate your account from the activation link sent to <b>$getemail</b>."; $getuser = ""; $getemail = ""; } else $errormsg = "An error has occueed. Your activation email was not sent."; } else $errormsg = "An error has occured. Your account was not created."; } else $errormsg = "There is already a user with that email."; } else $errormsg = "There is already a user with that username."; mysql_close(); } else $errormsg = "You must enter a valid email address to register."; } else $errormsg = "Your passwords did not match."; } else $errormsg = "You must retype your password to register."; } else $errormsg = "You must enter your password to register."; } else $errrosmg = "You must enter your email to register."; } else $errormsg = "You must enter your username to register."; }
$form = "<form action='./reg2.php' method='post'> <table> <tr> <td></td> <td><font color='red'>$errormsg</font></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='user' value='$getuser' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' value='$getemail' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='pass' value='' /></td> </tr> <tr> <td>Retype:</td> <td><input type='password' name='retypepass' value='' /></td> </tr> <tr> <td></td> <td><input type='submit' name='registerbtn' value='Register' /></td> </tr> </table> </form>";
echo $form;
?>
obviously, I got the reg code from youtube. (nickfrosty btw.) and my login.php in-case you need it.: - Code:
-
<form name="login" style="vertical-align:middle;" method="post" action="login.php"> <label style="float:left;">Username</label>
<br>
<input type="text" name="username" style="margin-top:5px; margin-bottom:5px;width:100%;height:15px;border-style:solid;border-width:0px;border-color:#403c3c;">
<br>
<label style="float:left;">Password</label>
<br> <input type="password" name="password" style="margin-top:5px;margin-bottom:5px; width:100%;height:15px;border-style:solid;border-width:0px;border-color:#403c3c;">
<br><br>
<span style=" width:100%;text-align:right;float:right;"> <a href="#" id="hide">Create an account!</a> <input type="submit" class="button" id="sumbit_btn" name="submit" value="Login"/></span> </form>
and yeah I already did search on google but it didn't helped me. |
|
Skilletrockz Super Moderator
![Super Moderator Super Moderator](https://2img.net/h/i654.photobucket.com/albums/uu265/hoover78/User%20ranks/supermod.png)
![Skilletrockz](https://2img.net/u/1111/11/56/92/avatars/165-69.jpg)
Posts : 45 Join date : 2011-05-11
![Ajax/jQuery Form $_POST and use PHP? Empty](https://2img.net/i/fa/empty.gif) | Subject: Re: Ajax/jQuery Form $_POST and use PHP? Wed May 11, 2011 10:03 pm | |
| |
|