Jump to content

PHP Automatic Form Submit


hittesh_ahuja

Recommended Posts

Hi Guy,

 

First Post ..so please help!

 

I have rows returning from a mYSQL Database which  I put in a form which is php generated and im sending this form to the next page with a SUBMIT button. I want PHP/Javascript to do this automatically when the data is loaded from the MYSQL Table

 

Ive tried fsockpen and document.form.submit() but it doesnt seem to work

 

Any help.

Thanks in Adv,

Hittesh Ahuja

<?php session_start();
if(isset($_POST['submit']))
{
header("Location: http://localhost/PHP/brk_plan.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<p>
  <?php 
require_once('connect.php');
	$email=$_SESSION['email'];

	$query="SELECT glycemic_index.gi_id,glycemic_index.value FROM food_preference JOIN glycemic_index ON glycemic_index.gi_id=food_preference.gi_id WHERE food_preference.email='$email' and glycemic_index.value >= 55 " or die("Update not Possible");
	$result=mysql_query($query);

	$session_array=array();
	echo "<form method='post' action='brk_plan.php' name='recommend'>";
	echo "<p>This area is filtered from the user's table showing values only > 55</p>";
	while($row=mysql_fetch_array($result))
	{


	echo "Instead of: ".$row[0]."-".$row[1]."<br/>";




	$one=$row[0];

	 $one_trimmed=substr($one,2,strlen($one)-5);

	 $one_search="%".$one_trimmed."%";


		$query2="SELECT glycemic_index.gi_id,glycemic_index.value,glycemic_index.food FROM glycemic_index WHERE glycemic_index.gi_id LIKE '$one_search' AND glycemic_index.value <55 AND glycemic_index.gi_id!='$row[0]' ORDER BY RAND() LIMIT 1  ";
	$result2=mysql_query($query2);

	while($row2=mysql_fetch_array($result2))
	{


		echo "<input type='hidden' value='$row2[2]' name='fields[]'></input>";			
	echo "<p>You can have ".$row2[2].": ".$row2[0]."-".$row2[1]."</p>";

	}	



	}

	echo "<input type='submit' name='submit' value='dikha!'></input>";
	echo "</form>";










	//$_SESSION['higher_gi']=$session_array;
	//foreach($session_array as $value)
//{
// echo $value."<br/>";

//}
?>
</p>
<p></p>
<p></p>

<p></p>
<p></p>
<p> </p>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/210873-php-automatic-form-submit/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.