PHP FORM SUBMISSION WITHOUT SUBMIT BUTTON

Links for php scripts

Moderators: macek, egami, gesf

prashhant
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Jun 08, 2012 6:09 am

PHP FORM SUBMISSION WITHOUT SUBMIT BUTTON

Postby prashhant » Fri Jun 08, 2012 6:15 am

Hi Friends,

I have used submit button in but is there any other way to submit the form data using <a> tag in an form. ???

prashhant
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Jun 08, 2012 6:09 am

Re: PHP FORM SUBMISSION WITHOUT SUBMIT BUTTON

Postby prashhant » Fri Jun 08, 2012 6:53 am

I actually have an form with this code instead of <input type =" submit">

<tr>
<td valign="top">&nbsp;</td>
<td valign="top" style="padding-top:10px;"> <div class="button3" style="width:100px;" align="center"><a href="#" class="button_link">Submit</a></div></td>
</tr>



I have an php page by name contact.php and want to submit the form in the database... How will i be able to do it. ???

Please 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

Postby 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

Postby 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>


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest