Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use functions on forms 2

Status
Not open for further replies.

hos2

Programmer
Joined
May 6, 2002
Messages
418
Location
NL
I have a form which uses the sqlaction.php3 when submitted. I was now wondering if I could not incorporate it as a function and that after finishing the function the same page is reloaded where it was submitted on ??

Is it possible/recommend to use functions instead of files to execute ?? or has it disadvantages ??
 
hmmm I had it for now with the function in the form. I just investigated the method I tried to use before but didn't work. I got it workin now. OK I won't win the beaty contest with it but it has te be finished by tomorrow


here is the last bit of code of the sqlaction file where I submit to for those who are interested. (the rest is above in this topic with a slight change of the insert statment
Code:
	$query="INSERT INTO " . $tablearray[$tablekey] . " SET ". $fieldlines;
	$rs=mysql_query($query,$conn);	
	$keyvalue=mysql_insert_id();
)

Code:
?>
<HTML>
<HEAD>
<TITLE>Record updated</TITLE>
<META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;>
<script language=&quot;javascript&quot;>
function move(url)
{
window.location.replace(url);
}
move('<? 
if ($tablekey == 'orid') {echo &quot;orform.php3?orid=$keyvalue&quot;;}
if ($tablekey == 'arid') {echo &quot;arform.php3?arid=$keyvalue&quot;;}
if ($tablekey == 'clid') {echo &quot;clform.php3?clid=$keyvalue&quot;;}
if ($tablekey == 'orlid') {echo &quot;orlineform.php3?orlid=$keyvalue&quot;;}
if ($tablekey == 'cltid') {echo &quot;cltform.php3?cltid=$keyvalue&quot;;}

?>');
</script>
</head>
</html>&quot;);
<?
mysql_close($conn);
?>

 
and because it's almost christmas I give some stars for you're patience and the fact that I know now that I'm stupid instead of php ;)
 
Instead of this:
Code:
move('<? 
if ($tablekey == 'orid') {echo &quot;orform.php3?orid=$keyvalue&quot;;}
if ($tablekey == 'arid') {echo &quot;arform.php3?arid=$keyvalue&quot;;}
if ($tablekey == 'clid') {echo &quot;clform.php3?clid=$keyvalue&quot;;}
if ($tablekey == 'orlid') {echo &quot;orlineform.php3?orlid=$keyvalue&quot;;}
if ($tablekey == 'cltid') {echo &quot;cltform.php3?cltid=$keyvalue&quot;;}
?>');

Do this:
Code:
move('orform.php3?<?= $tablekey ?>=<?= $keyvalue?>');

Take Care,
Mike
 
also an idea but now I can also define myself where it's going to after adding an orderline I can now directly go back to the order
like
Code:
if ($tablekey == 'orlid') {echo &quot;orform.php3?orid=$orlorid&quot;;}

when I added a new orderline. In you're example that's not possible


 
ah! I didn't notice that you were posting to different pages.

I don't know if you want do the following:
1) Combine all the different pages you post to into one page.
2) Differentiate between the type of form posted using the switch() statement.

Just an idea, don't know if that will work for you.

Take Care,
Mike
 
perhaps later on I will look at that. but this is just a small ordersystem for a bookingsagency. I first made the above handling form which saves me a lot of time. when I have to add a new field I only have to add it in mysql and to the form and that's all. the submitscript will take care of it automaticaly. I only had the problem that it staid at the submit form when finished

but like now you can also have the fuzzy logic that you want to jump back to an other form (after editing or adding a new orderline). for tonight I have succeeded in doing so
 
Cool :) glad its working now :)

Merry Christmas!

Take Care,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top