CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Jun 2017
    Posts
    1

    Registration form wont send data to phpmyadmin

    Hi, ive created a registration form but when i submit it, it wont send data to a table i created in php myadmin so i thnk i may have made a mistake somewhere. here is the code..

    HTML Code:
    <?php
    require 'dbconfig/config.php';
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title>Registration Page</title>
    <link rel="stylesheet" href="css/style.css">
    </head>
    <body style="background-color:#0c2177">
    
    <div id="main-wrapper">
    <center>
    <h2>Registration Form</h2>
    <img src="images/avatar.png" class="avatar"/>
    </center>
    
    <center>
    <form class="loginform" action="register.php" method="POST">
    <label><b>First Name:<b></label><br>
    <input name="firstname" type="text" class="inputvalues" placeholder="Enter First Name" required/><br>
    <label><b>Last Name:<b></label><br>
    <input name="lastname" type="text" class="inputvalues" placeholder="Enter Last Name" required/><br>
    <label><b>Email Address:<b></label><br>
    <input name="email" type="email" class="inputvalues" placeholder="Enter Email Address" required/><br>
    <label><b>Password:<b></label><br>
    <input name="password" type="password" class="inputvalues" placeholder="Enter Password" required/><br>
    <label><b>Confirm Password:<b></label><br>
    <input name="cpassword" type="password" class="inputvalues" placeholder="Confirm Password" required/><br>
    <input name="submit_btn" type="submit" id="signup_btn" value="Sign Up"/><br><br><br>
    <input type="button" id="back_btn" value="Back To Login Page"/>
    </center>
    </form>
    
    <?php
    if(isset($_POST['submit_btn']))
    {
    	echo '<script type"text/javascript"> alert("sign up button clicked") </script>';
    	
    	$firstname = $_POST['firstname'];
    	$lastname = $_POST['lastname'];
    	$email = $_POST['email'];
    	$password = $_POST['password'];
    	$cpassword = $_POST['cpassword'];
    	
    	if('$password'=='$cpassword')
    	{
    		$query= "select * from user WHERE email='$email'";
    		$query_run = mysqli_query($con,$query);
    		
    		if(mysqli_num_rows($query_run)>0)
    		{
    			// this email address is already registered
    			echo '<script type="text/javascript"> alert("Email Address Already Registered") </script>';
    			{	
    			}
    			$query= "insert into values('$firstname','$lastname','$email','$password','$cpassword')";
    			$query_run = mysqli_query($con,$query);
    			
    			if($query_run)
    			{
    			echo '<script type="text/javascript"> alert("Registration Successful.. return to login page") </script>';	
    			}
    			else
    			{
    			echo '<script type="text/javascript"> alert("ERROR!") </script>';	
    			}
    				
    		}
    		
    		
    	}
    
    }
    ?>
    </div>
    
    </body>
    </html>
    Last edited by 2kaud; June 13th, 2017 at 03:35 AM. Reason: Added code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured