alin19 Posted November 7, 2007 Share Posted November 7, 2007 can i include more forms on a php page? something like this: <html> .... <form method="get"> <input type="text" name="unu" size=7> </form> <form method="get"> <input type="text" name="doi" size=7> </form> <form method="get"> <input type="text" name="trei" size=7> </form> <?php $a=$_get['unu] $b=$_get['doi]' ........... $x= $a*$b +$c; echo x; ?> i need a little help Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 7, 2007 Share Posted November 7, 2007 Why do you need more Forms ? One is sufficient... Quote Link to comment Share on other sites More sharing options...
alin19 Posted November 7, 2007 Author Share Posted November 7, 2007 that works but it gives me an error, because the var $get_[unu] and doi are not difined, Quote Link to comment Share on other sites More sharing options...
adam291086 Posted November 7, 2007 Share Posted November 7, 2007 post the code for your code for the form and the php, then we can help Quote Link to comment Share on other sites More sharing options...
aschk Posted November 7, 2007 Share Posted November 7, 2007 Multiple html forms is perfectly valid. Imagine a list of holidays, and each one has to be "POST"ed to a handling page that checks the availability of it. You don't want to post ALL the holidays in your list... just one of them, with it's separate variables. However, you have a flaw in your logic, and for what you need you need just 1 form not 3. <form method="GET" action="otherpage.php"> <input type="text" name="unu" size="7" /> <input type="text" name="doi" size="7" /> <input type="text" name="trei" size="7" /> </form> And you then need a page that takes what you've sent to it (otherpage.php) <?php $a = $_GET['unu']; $b = $_GET['doi']; ..... $x = $a*$b+$c; echo $x; ?> You CANNOT use $_GET variables that you have not submitted yet. When that page you have written gets parsed by PHP it looks for the $_GET variables you are asking it for. But NOTHING has been sent from a form to the server yet so it causes an error. Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 7, 2007 Share Posted November 7, 2007 I think you are trying to do like this <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { $a = $_POST['unu']; $b = $_POST['doi']; $c = $_POST['trei']; $x = $a * $b + $c; } ?> <form name="check" method="post"> <table width="304" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td height="35" valign="top"><?php if(isset($x)) { echo $x; } ?></td> </tr> <tr> <td width="304" height="79" valign="top"> <input name="unu" type="text" id="unu" /> </td> </tr> <tr> <td height="86" valign="top"><input name="doi" type="text" id="doi" /></td> </tr> <tr> <td height="86" valign="top"><input name="trei" type="text" id="trei" /></td> </tr> <tr> <td height="86" valign="top"><input type="submit" name="Submit" value="Submit" /></td> </tr> </table> </form> If there is some programming or logical error , I will be glad to hear Quote Link to comment Share on other sites More sharing options...
alin19 Posted November 7, 2007 Author Share Posted November 7, 2007 you are a genius works, i'm a beginer, i have a few questions, i need a script that dosn't need to be run in a browser i've understand that php-cli makes that, but i don't know how to use it Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 7, 2007 Share Posted November 7, 2007 you are a genius works, Who told you that i just started PHP 4 mths ago, I am a beginner too i'm a beginer, i have a few questions, i need a script that dosn't need to be run in a browser For that I think you need to refer www.php.net and read more about these things... Command line scripting. You can make a PHP script to run it without any server or browser. You only need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows). These scripts can also be used for simple text processing tasks. See the section about Command line usage of PHP for more information. Writing desktop applications. PHP is probably not the very best language to create a desktop application with a graphical user interface, but if you know PHP very well, and would like to use some advanced PHP features in your client-side applications you can also use PHP-GTK to write such programs. You also have the ability to write cross-platform applications this way. PHP-GTK is an extension to PHP, not available in the main distribution. If you are interested in PHP-GTK, visit its own website. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.