HardCoreMore Posted March 30, 2008 Share Posted March 30, 2008 HI, I have problem with joining tables in php. This is how my two tables look like: So for example when user is registered on site with this script I use table users to store user info : <?php session_start(); $user = $_POST["user"]; $pass = $_POST["pass"]; $con_pass = $_POST['con_pass']; $email = addslashes ($_POST["email"]); if( isset($_POST['submit'])) { if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { unset($_SESSION['security_code']); include_once("validChar.php"); if (!$_POST['user'] && !$_POST['pass'] && !$_POST['email']) { echo "All field with stars are required."; }else{ if (restrictedChar ()) { echo "These characters are not allowed"; }else{ if($_POST['pass'] != $_POST['con_pass']) { echo "Your password dosen't match."; }else{ if (!isValidEmail($email)) { echo "Email address in not valid, please enter valid emailaddress."; }else{ $db = mysql_connect("localhost","root","chaky"); mysql_select_db("userlist",$db); $selectName = mysql_query("SELECT * FROM users where name ='$user'")or die (mysql_error()); $selectEmail = mysql_query("SELECT * FROM users where email ='$email'")or die (mysql_error()); $roweName = mysql_fetch_assoc($selectName); $roweEmail =mysql_fetch_assoc($selectEmail); if ($user && $pass && $email) { if ($roweName['name'] == $user) { echo "Ime je vec zauzeto, probajte neko drugo"; }else{ if ($roweEmail['email'] ==$email) { echo "Email adresa je vec zauzeta, molimo unesite drugu email adresu"; }else{ mysql_query ("insert into users set name = '$user', password = password('$pass'),email = '$email'"); echo "Your details have been added to the database, ".$user."<br />\n\n\n"; echo "<a href='main.php'>Click here to go to proceed to the main page.</a><br /><br />\n\n\n"; echo "<a href = 'logout.php'>Click here to logout.</a>"; mysql_close($db); echo $roweName['name']; echo "<br />"; echo $roweEmail['email']; $checkSuccess = 1; exit; } } } } } } } // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. } else { // Insert your code for showing an error message here echo 'Sorry, you have provided an invalid security code'; } } if ($checkSuccess !=1) { $thisFile = $_SERVER['PHP_SELF']; $form = <<< regForm <title>Register</title> <h1>Register</h1> <form method="post" action="$thisFile"> Please enter a username:* <input name="user" type="text" maxlength="20" size="20" class="user" /> <br /> <br /> Please enter a password:* <input name="pass" type="password" maxlength="10" size="10" class="pass" /> <br /> <br /> Please confirm your password:* <input name="con_pass" type="password" maxlength="10" size="10" class="conf_pass" /> <br /> <br /> Please enter your email:* <input name="email" type="text" maxlength="30" size="30" class="email" /> <br /> <br /> Type security code:* <input type="text" name="security_code" maxlenght="8" size="10" class="sec_code" /> <br /> <br /> <input type="submit" value="Register" name="submit" /> </form> regForm; print $form; } function isValidEmail($email) { return eregi("^([a-z0-9_]+\\.[a-z0-9]|[a-z0-9_])+@[a-z0-9\\-]+\\.[a-z0-9\\-\.]+$","$email"); } $secPic = <<< bla <p>Security picture.</p> <table width="150" height="75" border="0"> <tr> <td><img src="securityIm.php" /></td> </tr> </table> bla; print $secPic; ?> <style type="text/css"> .user{margin-left:2cm} .pass{margin-left:2cm} .conf_pass{margin-left:1cm} .email{margin-left:2cm} .sec_code{margin-left:2.8cm} </style> I don’t know how to set same userID in user_docs table as it is in users table where user register. Is that supposed to be set in php or mysql. I need that so I can join tables . Can anyone help please. Link to comment https://forums.phpfreaks.com/topic/98684-joining-table/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.