How to make contact form in php | Html

Login_Form_by_Berk_OztoprakContact form in PHP or HTML is easy task for beginner, High profile programmer never think how to do this because this is just simple in few steps.I hope you are looking for just users input values either get on your mail or store in database.I tell you both by which you store user info in database store & mail to your particular e-mail.Now its time to follow me for making contact form.

First I tell you how to make form in html

So lets start with basic html page in which these base parameter should be written before.

<html>

<head>

</head>

<body>

</body>

</html>

For make page speed high you should have to make css sheet different. I am teach you form css in just moment ,for that we are strongly working to launch our Learning media module in which a large collection of tutorial we will provide.So now a simple php html form i make for you.

Simple Form html is here

<form name="reg" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="fname" placeholder="First name" />
    <input type="text" name="email" placeholder="E-mail" />
      <input type="text" name="lname" placeholder="lastname" />
  <input type="text" name="website" placeholder="Website Url" />
<input id="username" name="username" type="text" value="" placeholder="Username" onBlur="return check_username();" />
<input type="password" name="password" placeholder="Password" />
<input type="password" name="password1" placeholder=" Repeat-Password" />
    <input name="submit" type="submit" value="Submit" />
</form>

This one is simple & basic form code in which you can use any of css to give perfect design according to your website.Let me Explain how form data get in your mail or database .If can see i am using name=”” in every input value this name i use in php form value submission that fetch your input values.Here is php code for submit data in database & mail to your mail.

<?php 
$firstname=$_POST['fname'];
$lastname=$_POST['lname'];
$email=$_POST['email'];
$username=$_POST['username'];
$password=$_POST['password'];

 
                // Selecting Database
                  mysql_select_db($mysql_database, $bd);
                  $result = mysql_query("SELECT * FROM users WHERE email='$email'");
                  $data = mysql_num_rows($result);

$to = $email;
$from = "[email protected]";
$subject = "Activate your Account";
$message = "Message here ";

$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=utf-8\r\n";
$headers .= "From: \"" . $from . "\" \r\n";
$headers .= "Reply-To: " . $to . "\r\n";
$message = utf8_decode($message);

mail($to, $subject, $message, $headers);
 if(($data)==0){
                    //Insert query

mysql_query("INSERT INTO users(firstname, lastname, email, username, password, timedate,)VALUES('$firstname', '$lastname','$email', '$username', '$password', now(),)");
header("location: ../login");
mysql_close($con);
} 
?>

Attach database in php to submit in database

DO NOT FORGET TO HELP YOU AGAIN IF YOU GET ANY DIFFICULTY.

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *