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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple PHP Help 1

Status
Not open for further replies.

perlone

Programmer
May 20, 2001
438
US
I don't really know if it's simple in php, but in perl I would use the exit function for this. Go here:


And click on the submit button and it will display "Pressed submit!" but how do I write that in a new section instead of under the form? Thanks for your time. I just started woking with PHP 2 days ago. There is no Knowledge, That is not power.
Age: 16
E-mail: projectnet01@yahoo.com
School: Coral Springs High (Company:(not done yet) :)
Status: Currently working with C++ for game developing.
-Aaron
 
"exit;" works the same in PHP as it does in Perl. In fact many of the basic language constructs will be the same, except for differences in how you express arrays, filehandles, and regular expressions. (well, you can even have Perl-compatible regular expressions, but how you get in and out of them is still different.)
 
Still not working. I have the following code after the </form> tag:

<?
if ($action) {
echo &quot;Pressed submit!&quot;;
exit;
}
?> There is no Knowledge, That is not power.
Age: 16
E-mail: projectnet01@yahoo.com
School: Coral Springs High (Company:(not done yet) :)
Status: Currently working with C++ for game developing.
-Aaron
 
you've got it backwards. Try placing that code before the beginning <form> tag.

The exit command simply halts any further output after it; it has no other function, so if you place the exit command after your </form> tag, the whole form will be displayed, and then the script will halt any further display, meaning any HTML that comes after it, such as </body> and </html>. Thus if you want to have a conditional outputting of HTML, you might want to put </body></html> inside those braces:

Code:
Top html stuff here...
<?php
if ($action) {
echo &quot;Pressed submit!&quot;;
echo &quot;</body></html>&quot;
exit;
}
?>
<form method=&quot;POST&quot;>
Form stuff here...
</form>
</body>
</html>
 
Thank You, works like a charm :) There is no Knowledge, That is not power.
Age: 16
E-mail: projectnet01@yahoo.com
School: Coral Springs High (Company:(not done yet) :)
Status: Currently working with C++ for game developing.
-Aaron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top