I am trying to use this script to enter data into my database from an html form. this code is not working. plz tell me where the error is
form is

<html>
    
<head>
    <title> Review, Ratings, Opinions Site </title>
</head>
 
<body text="green" >
<form action="register processing.php" method="post" >
        First name: <input type="text" name="fname" value="empty" />           <br/>
        Last name:  <input type="text" name="lname" value="empty" />            <br/> 
        Gender:<br/><input type="radio" name="sex" value="male" />   MALE 
                    <input type="radio" name="sex" value="female" />  FEMALE              <br/>      
        Email id:   <input type="text" name="email" value="empty" />       <br/>
        Username:   <input type="text" name="username" value="empty" />          <br/> 
        password:   <input type="password" name="password" value="empty" />      <br/>
                    <input type="submit" name="submit" value="submit" />
    </form>
    
</body>

</html>

and the action file is

<?php
      $handle = mysql_connect("localhost", "root");
      if(!$handle)
        die("mysql connection failed due to :" . mysql_error());


      $db = mysql_select_db ("review_site" , $handle );
      if(!db)
       die("database selection failed due to :" . mysql_error());
?>
<html>
<head>
    <title> server side proceesing </title>
</head>

<body>
    <?php
     $fname = $_REQUEST['fname'];
     $lname = $_REQUEST['lname'];
     $sex =   $_REQUEST['sex'];
     $email=  $_REQUEST['email'];
     $username=$_REQUEST['username'];
     $password= $_REQUEST['password'];
     $v= 1;
     $sql = "INSERT INTO users(fname,lname,sex,email,username,password,visible)
      VALUES($fname,$lname,$sex,$email,$username,$password,$v)" ;   
      if($result = mysql_query ($sql, $handle ))
        {echo "welcome " . $fname . "<br/>";}
     ?>    
</body>     
</html>

why r you using php code with in the body tags. are you connected with database?

if yes, then echo your query and paste it in phpmyadmin query area and then check your query is right or wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.