Jump to content

form add


alin19

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

you are a genius :) works,

 

Who told you that  ;D 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.

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.