Is it possible to use "php coding" in same form design page as in mentioned below

// this my coding, if i click submit button php code is not running… its showing error the requested url was not found on this server php

<html>
<head>
<title>register</title>
<link href="jqstyle.css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://jquery.bassistance.de/validate/jquery.validate.js"></script>
<script src="http://jquery.bassistance.de/validate/additional-methods.js"></script>
  
  <!-- jQuery Form Validation code -->
  <script>  
  // When the browser is ready...
  $(function() {
    // Setup form validation on the #register-form element
    $("#register-form").validate({
        // Specify the validation rules
     rules: {
            name: {
                required: true,
                rangelength: [1,14]
            },
            phone: {
			required:true,
			digits:true,
			rangelength:[10,10]
			},
            email: {
                required: true,
                email: true
            },
            password: {
                required: true,
                minlength: 5
            },
            
        },
        
        // Specify the validation error messages
        messages: {
            name:{
			required:"Please enter your name",
			rangelength:"too lengthy"
			},
            phone: {
			required:"Please enter your phone number",
			rangelength:"check your number"
			},
            password: {
                required: "Please provide a password",
                minlength: "Your password must be at least 5 characters long"
            },
            email: "Please enter a valid email address",
        },
        
        submitHandler: function(form) {
            form.submit();
        }
    });

  });
  
  </script>
 
</head>
<body>
 <?php
  $conn=mysql_connect("localhost","root","");
  or die("cannot connect");
  ?>
<fieldset>
<legend>Registeration</legend>
  <!--  The form that will be parsed by jQuery before submit  -->
  <form action="jqsty.php" method="post" id="register-form" >
  
  <ul>
        <li>
        	<label for="name1">Name:</label>
            <input type="text" size="30" id="name" name="name" />
        </li>
		
		<li>
		    <label for="phone1">Phone Number:</label>
		    <input type="text" size="30" id="phone" name="phone" />
	    </li>
	 
		<li>
			<label for="email1">E-mail:</label>
			<input type="email" size="30" id="email" name="email" />
        </li>
		
	    <li>
			<label for="password1">Password:</label>
			<input type="password" size="30" id="password" name="password" />
		</li>
<p>
   <input type="submit" class="submit1" value="Submit" /></div>
   <input type="reset" class="reset1" value="Reset"/>
</p>

 </ul>
  </form>
  </fieldset>
</body>
</html>

Hi selva1990. Welcome to the forums. :slight_smile:

For this to work, the jqsty.php file needs to be in the same directory/folder as the page on which the form appears.

thank you so much for reply… but jqsty.php is the single file… in form action i gave action = “jqsty.php” and forn name is “jqsty.php”… i wrote my php code in head tag… if i click submit button i need to get database error but its not working showing error… the requested url was not found on this server php… nd my server is working fine, if i run someother file its working…

If the PHP for processing the form is at the top of the page itself, then change the action=“” part to this:

action="[COLOR="#FF0000"]<?php $_SERVER['PHP_SELF'] ?>[/COLOR]"

But the PHP code should be at the top of the page, above the doctype, rather than in the <head>. In the code you posted, you have the JS in the <head>, but no PHP.

<?php
$conn=mysql_connect(“localhost”,“root”,“”);
or die(“cannot connect”);
?>

<html>
<head>
<title>register</title>
<link href=“jqstyle.css” rel=“stylesheet” />
<script src=“http://code.jquery.com/jquery-1.9.1.min.js”></script>
<script src=“http://jquery.bassistance.de/validate/jquery.validate.js”></script>
<script src=“http://jquery.bassistance.de/validate/additional-methods.js”></script>

<!-- jQuery Form Validation code –>
<script>
// When the browser is ready…
$(function() {
// Setup form validation on the #register-form element
$(“#register-form”).validate({
// Specify the validation rules
rules: {
name: {
required: true,
rangelength: [1,14]
},
phone: {
required:true,
digits:true,
rangelength:[10,10]
},
email: {
required: true,
email: true
},
password: {
required: true,
minlength: 5
},

    },
    
    // Specify the validation error messages
    messages: {
        name:{
		required:"Please enter your name",
		rangelength:"too lengthy"
		},
        phone: {
		required:"Please enter your phone number",
		rangelength:"check your number"
		},
        password: {
            required: "Please provide a password",
            minlength: "Your password must be at least 5 characters long"
        },
        email: "Please enter a valid email address",
    },
    
    submitHandler: function(form) {
        form.submit();
    }
});

});

</script>

</head>
<body>
<fieldset>
<legend>Registeration</legend>
<!-- The form that will be parsed by jQuery before submit –>
<form action=“<?php $_SERVER[‘PHP_SELF’] ?>” method=“post” id=“register-form” >

<ul>
<li>
<label for=“name1”>Name:</label>
<input type=“text” size=“30” id=“name” name=“name” />
</li>

	&lt;li&gt;
	    &lt;label for="phone1"&gt;Phone Number:&lt;/label&gt;
	    &lt;input type="text" size="30" id="phone" name="phone" /&gt;
    &lt;/li&gt;
 
	&lt;li&gt;
		&lt;label for="email1"&gt;E-mail:&lt;/label&gt;
		&lt;input type="email" size="30" id="email" name="email" /&gt;
    &lt;/li&gt;
	
    &lt;li&gt;
		&lt;label for="password1"&gt;Password:&lt;/label&gt;
		&lt;input type="password" size="30" id="password" name="password" /&gt;
	&lt;/li&gt;

<p>
<input type=“submit” class=“submit1” value=“Submit” /></div>
<input type=“reset” class=“reset1” value=“Reset”/>
</p>

</ul>
</form>
</fieldset>
</body>
</html>

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

localhost
Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.19

thank u for your response… as u said i put php code in top and also tried in head tag, but i got the same error i mentioned above…

its working thank u so much