dean012 Posted November 27, 2013 Share Posted November 27, 2013 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...l1-strict.dtd"> <!-- --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Yakity Yak</title> <link href='http://fonts.googlea...=Oswald:400,300' rel='stylesheet' type='text/css'> <link href='http://fonts.googlea...css?family=Abel|Satisfy' rel='stylesheet' type='text/css'> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <p><!-- end #header --></p> <div id="header" class="container"> <div id="logo"> <h1><a href="#">Yakity Yak</a></h1> </div> <div id="menu"> <ul> <li class="current_page_item"><a href="homepage.php">Homepage</a></li> <li><a href="trip.php">Destinations</a></li> <li><a href="contact.php">contact </a></li> <li><a href="login.php">Login</a></li> <li><a href="#">Leader</a></li> <li></li> <li></li> </ul> </div> </div> <blockquote> <blockquote> <p> <center><img src="sd.jpg" width="999" height="300" alt=""/></center> </p> </blockquote> </blockquote> <div id="page"> <div class="post"> <h2 class="title"><a href="#">Welcome to Yakity yak club</a></h2> <form method='post' action='login.php'> <table width='400' border='5' align='CENTER'> <tr> <td><h1>Registration</h1></td> </tr> <tr> <td>User Name:</td> <td><input type='text' name='name'/></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='pass'/></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email'/></td> </tr> <tr> <td><input type='submit' name='register' value='register'/></td> </tr> </table> </form> </body> </html> <div class="entry"> <br><center><b>Already Registered?</br></b></center> <center><a href='login.php'> login here</a></center> </div> </div> </div> </body> </html> <?php $connect=mysql_connect("localhost","root",""); $db_selected = mysql_select_db("users_db", $connect); if(isset($_POST['submit'])){ $users_name = $_POST['name']; $users_pass = $_POST['pass']; $users_email = $_POST['email']; if($users_name==''){ echo "<script>alert('Please enter your Username')</script>"; exit(); } if($users_pass==''){ echo "<script>alert('Please enter your password')</script>"; exit(); } if($users_email==''){ echo "<script>alert('Please enter your email')</script>"; exit(); } $check_email="select*from users where users_email='$users_email'"; $run = mysql_query($check_email) or die(mysql_error()); if(mysql_num_rows($run)>0){ echo"<script>alert('Email $users_email is already exist in our databse, please try another one')</script>"; exit(); } $query = "insert into users (users_name,users_pass,users_email) values(' $users_name','$users_pass','$users_email')"; if(mysql_query($query)) $result = mysql_query($query) or die(mysql_error()); if ($result) { echo "<script>alert('Registration Successfull!')</script>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/ Share on other sites More sharing options...
cyberRobot Posted November 28, 2013 Share Posted November 28, 2013 (edited) Did you try using mysql_error() after the insert query to see what you get? Edit: try changing this: if(mysql_query($query)) $result = mysql_query($query) or die(mysql_error()); if ($result) { echo "<script>alert('Registration Successfull!')</script>"; } To this: if($result = mysql_query($query)) { echo "<script>alert('Registration Successfull!')</script>"; } echo mysql_error(); Edited November 28, 2013 by cyberRobot Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460431 Share on other sites More sharing options...
dean012 Posted November 28, 2013 Author Share Posted November 28, 2013 No index defined Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460433 Share on other sites More sharing options...
dean012 Posted November 28, 2013 Author Share Posted November 28, 2013 still not working Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460434 Share on other sites More sharing options...
mac_gyver Posted November 28, 2013 Share Posted November 28, 2013 if the form you have shown is the form that is being submitted, it doesn't have a field named submit and your php logic testing if(isset($_POST['submit'])){ will never be true. what debugging have you done to pin down what your code is actually doing? Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460440 Share on other sites More sharing options...
dean012 Posted November 28, 2013 Author Share Posted November 28, 2013 debugging?whats that? Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460441 Share on other sites More sharing options...
KevinM1 Posted November 28, 2013 Share Posted November 28, 2013 debugging?whats that? ... You're kidding, right? If not, debugging is a term that means taking the steps necessary to remove the bugs (stuff that doesn't work like it should) from your code. mac_guyver was asking what steps have you taken to try to fix your problem? Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460444 Share on other sites More sharing options...
cyberRobot Posted November 28, 2013 Share Posted November 28, 2013 debugging?whats that? Perhaps the following definition will help: https://www.google.com/search?q=define+debug First off, you should try echoing $_POST to see what it contains. Since it's an array, you could try the following: echo '<pre> ' . print_r($_POST, true) . '</pre>'; As mac_gyver suggested, your form doesn't have an input field named "submit". Instead of if(isset($_POST['submit'])){ Try if(isset($_POST['register'])){ Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460445 Share on other sites More sharing options...
dean012 Posted November 28, 2013 Author Share Posted November 28, 2013 still not working ;( <?php $connect=mysql_connect("localhost","root",""); $db_selected = mysql_select_db("users_db", $connect); if(isset($_POST['register'])){ echo '<pre> ' . print_r($_POST, true) . '</pre>' $users_name = $_POST['name']; $users_pass = $_POST['pass']; $users_email = $_POST['email']; Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460446 Share on other sites More sharing options...
cyberRobot Posted November 28, 2013 Share Posted November 28, 2013 Did the following line echo anything? Are you getting any errors? Note that you forgot the semicolon: echo '<pre> ' . print_r($_POST, true) . '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460451 Share on other sites More sharing options...
objnoob Posted November 28, 2013 Share Posted November 28, 2013 (edited) Sorry, never mind me. I'm dumber than dumb! Or, is it I'm dumb then dumber? Wait ... Edited November 28, 2013 by objnoob Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460455 Share on other sites More sharing options...
dean012 Posted November 28, 2013 Author Share Posted November 28, 2013 it doesnt echo out anything and no data is enetred to database Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460456 Share on other sites More sharing options...
objnoob Posted November 28, 2013 Share Posted November 28, 2013 the action of the form is going to login.php, your registration form + registration processing is happening some other place. <form method='post' action='login.php'> would probably work if you just omitted the action... which will typically submit the form back to the same URI <form method='post' action=''> or.... <form method='post' action='registration.php'> Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460458 Share on other sites More sharing options...
dean012 Posted November 28, 2013 Author Share Posted November 28, 2013 still not working Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460459 Share on other sites More sharing options...
aysiu Posted November 28, 2013 Share Posted November 28, 2013 Is the code here in a page called login.php? The POST data should go back to the same document the way it's written. P.S. mysql_fillintheblankcommand is deprecated. You should use mysqli_ or PDO commands instead. P.P.S. The way your login page is written, you're very vulnerable to SQL injection. You should use prepared statements instead of just querying on random data users submit. Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460463 Share on other sites More sharing options...
dean012 Posted November 28, 2013 Author Share Posted November 28, 2013 i used mysqli and pdo already none of them r working? Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460464 Share on other sites More sharing options...
aysiu Posted November 28, 2013 Share Posted November 28, 2013 (edited) The P.S. and P.P.S. won't solve your lack of POST data. They are just to make your code better (by the way, you don't use mysqli and PDO--you use one or the other). The second is really important, because it is a security issue. My main point was that the POST data existing assumes that the file you're posting code from is called login.php and is resubmitting to login.php. Can you verify that's the case? Edited November 28, 2013 by aysiu Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460465 Share on other sites More sharing options...
objnoob Posted November 28, 2013 Share Posted November 28, 2013 (edited) What you need to do, is check whether or not the form was submitted first. Your issue may be that you're outputting a full fledged document before anything else, and all other output after is not being presented on screen. That's why checking the source code is always helpful when debugging. The source code never hides anything. <?php if(isset($_POST['register'])){ // if submitted, validate data and connect to database }else{ // if not, show the registration form } Edited November 28, 2013 by objnoob Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460477 Share on other sites More sharing options...
objnoob Posted November 28, 2013 Share Posted November 28, 2013 Nevermind. You're using javascript. I'd expect that to execute when posting back to that page. I'm done here. Bye Quote Link to comment https://forums.phpfreaks.com/topic/284344-it-wont-enter-any-data-to-my-database/#findComment-1460481 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.