Drayen Posted April 27, 2008 Share Posted April 27, 2008 Sorry if I'm wording this wrong, here's my problem: The form: <html> <head> <title>Product Update</title> </head> <body> <form action="index.php" method="get"> Product: <input name="product" type="text" /> Starting Price: <input name="price" type="text" /> <br /> Description: <input name="description" type="text" /> <input type="submit"> </form> </body> </html> Part of the php file: function add() { $AAA = new AAA("Product", $_GET["product"], $_GET["price"], "images/unknown.jpg", $_GET["description"]); echo '<img src="'. $AAA->GetPhoto() .'" align="left" />'; echo '<b>'. $AAA->GetName() .'</b>: '. $AAA->GetModel(); echo '<p>Starting from: '. $ipod->GetPrice() .'</p>'; echo '<p>'. $AAA->GetDescription() .'</p>'; } Basically I don't want the fucntion add to execute unless it's being triggered by coming from the form page, so how would I go about doing this? Right now I just have the function add() above and it runs but that means it runs even when I'm not coming from the form site. Any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 27, 2008 Share Posted April 27, 2008 You need to check if the form has been submitted with isset() <?php if (isset($_GET['product']) AND isset($_GET['price']) AND isset($_GET['description'])) { // Add the product add(); } ?> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted April 27, 2008 Share Posted April 27, 2008 basically your check to see if the buttons been pressed, i updated the submit button with a name <input type="submit" name="submit" value="submit"> we then check to see if that element has a value *button name* i called it submit.. <html> <head> <title>Product Update</title> </head> <body> <?php //this is the key to getting it to work if(!empty($_GET['submit'])) { add(); } function add() { $AAA = new AAA("Product", $_GET["product"], $_GET["price"], "images/unknown.jpg", $_GET["description"]); echo '<img src="'. $AAA->GetPhoto() .'" align="left" />'; echo ''. $AAA->GetName() .': '. $AAA->GetModel(); echo '<p>Starting from: '. $ipod->GetPrice() .'</p>'; echo '<p>'. $AAA->GetDescription() .'</p>'; } ?> <form action="index.php" method="get"> Product: <input name="product" type="text" /> Starting Price: <input name="price" type="text" /> Description: <input name="description" type="text" /> <input type="submit" name="submit" value="submit"> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
Drayen Posted April 28, 2008 Author Share Posted April 28, 2008 Thanks guys 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.