PHP FORM SUBMISSION WITHOUT SUBMIT BUTTON

Links for php scripts

Moderators: macek, egami, gesf

Post Reply
rupali
New php-forum User
New php-forum User
Posts: 140
Joined: Thu Oct 13, 2011 10:32 pm
Location: Chandigarh, INDIA

Re: PHP FORM SUBMISSION WITHOUT SUBMIT BUTTON

Post by rupali » Fri Jun 08, 2012 9:18 pm

hello,

you can refer this script, hope it works for you :

<script type="text/javascript">
function submitform()
{
document.forms["myform"].submit();
}
</script>
<!-- give the path where you want to redirect the page and set the method attribute according to that -->
<form id="myform" action="">
Text: <input type='text' name='text'>
<a href="javascript: submitform()">Submit</a>
</form>

User avatar
shnkrsv
New php-forum User
New php-forum User
Posts: 27
Joined: Sun Oct 30, 2011 10:48 pm
Location: Coimbatore
Contact:

Re: PHP FORM SUBMISSION WITHOUT SUBMIT BUTTON

Post by shnkrsv » Sat Jun 09, 2012 11:27 pm

As my friend suggusted there's also another way.

Can try this.

No need for seperate file to insert.

Code: Select all

<?php
if(isset($_POST['submit']))
{

			$name2=$_POST['name1'];
			$des=$_POST['desc1'];
			$keyword=$des;
			$keyword = str_replace("'","\'",$keyword);
			$des=$keyword;
			$db_table=$_POST['category'];

include("config.php"); //Data base connectivity
$temp_name = trim($name2); //trim white space
$temp_des = trim($des); //trim white space
if(empty($temp_name))
{
	echo "<script type='text/javascript'>window.alert('Data not inserted. Article name filed should not left empty.')</script>";
}
if(empty($temp_des))
{
	echo "<script type='text/javascript'>window.alert('Data not inserted. Description filed should not left empty.')</script>";
}
else
{
    $insertdata = mysql_query("INSERT INTO $db_table values('','$name2','$des')");
	echo "<center><span id='admin_success_msg' >Successfully saved</span></center>";

}
}
?>

<form action="" method="post" enctype="multipart/form-data">
<table id="table_admin" align="center">

<tr>
<td width="170">Select the Category you have to insert data</td><td>:</td>
<td>
<select name="category" id="category" >
	<option value=''>--Select an Category--</option>
	<option value='tamil'>Tamil</option>
	<option value='telugu'>Telugu</option>
	<option value='hindi'>Hindi</option>
	<option value='spice'>Spice</option>
</select>
</td>
</tr>

<tr>
<td>Name of the Gallery</td><td>:</td><td><input type="text" name="name1"></td>
</tr>

<tr>
<td>Description about the Gallery</td><td>:</td><td><textarea rows="6" cols="40" name="desc1"></textarea></td>
</tr>

</table>

<table align="center" id="table_bottoms_admin">
<tr>
<td><input type="submit" value="Submit" name="submit"></td>
<td><input type="reset" value="Reset" name="clear" onClick="window.location.reload()"></td>
</table>

</form>

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests