FORM CODE -
<form method="POST" action="shareexperience.php" id="contactForm" name="sentMessage" target="formsaved">
<br/><textarea rows="5" cols="40" name="views" id="views" placeholder="Views About Your Profession">
</textarea> <br/>
<textarea rows="5" cols="40" name="advice" id="advice" placeholder="Advice 4 Students">
</textarea> <br/>
Wanna Be A Guide 4 Child
<input type="radio" id="yes" name="guide" value="Yes" checked> Yes </input>
<input type="radio" id="No" name="guide" value="No" > No </input>
<br/><input type="text" name="name" id="professionalname" placeholder="Name">
<input type="text" name="email" id="professionalemail" placeholder="Email Id"> <br/>
<br/><input type="submit" value="Share & Nominate" onclick="saveexperience()">
</form>
PHP CODE-
<? php
$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " .mysql_error());
//inserting Record to the database
$name = $_POST['name'];
$email = $_POST['email'];
$views = $_POST['views'];
$advice = $_POST['advice'];
$guide=$_POST['guide'];
$query = "INSERT INTO professionals(name,email,views,advice,guide)VALUES('$name','$email', '$views','$advice','$guide')";
$result = mysql_query($query);
mysql_close($con);
?>
Target formsaved has been used to avoid redirection by using html tag iframe as followed below-
<iframe name="formsaved" height="30px" width="300px" scrolling="no" frameborder="0"> </iframe>
Sometimes data enter fines but sometimes it doesn't work You can check my website as well - guidance4future.in/nominate
Note:- onclick has been used to disable one of the html tags in the page further...
Thanks in advance...
mysql_queryinterface. It's awful and has been removed in PHP 7. A replacement like PDO is not hard to learn and a guide like PHP The Right Way helps explain best practices. Your user parameters are not properly escaped and you have severe SQL injection bugs here.