Solved

PHP echo statement location within html

Posted on 2007-12-04
5
2,358 Views
Last Modified: 2013-12-13
so heres my code:

php
$link="http://www.website.com";
if(!isset($_POST['agree']) && isset($_POST["is_submit"]) && $_POST["is_submit"]==1)
{
echo "Please agree to the terms, it is all I am asking!";
}
else if(isset($_POST['agree']) && $_POST['agree']=="ON")
{
header("location:$link");
}
?>

<html>

<head>
<title>site</title>
</head>

<body>

Welcome to my site here is something to get started.
<form action="agree.php" method=POST>

<textarea name="textfield" rows="5" cols="25" wrap="virtual" readonly onFocus="this.blur();">OK so here are my terms and conditions.</textarea>

      <p><input type="checkbox" name="agree" value="ON">I Agree
      <input type=submit value="Login" style="float: left">
      <input type="hidden" name="is_submit" value="1">
      </p>
      &nbsp;</form>

</body>

</html>


how do position echo statements: i want my echo statement on line 5 (Please agree to the terms, it is all I am asking! Welcome to my site here is something to get started.)
to appear after the login button to the right same line....

and what is a good source for placing or positioning php code within html designs?
0
Comment
Question by:bcmeyer1983
  • 2
  • 2
5 Comments
 
LVL 2

Author Comment

by:bcmeyer1983
ID: 20408306
apologies omit this phrase in the question above:
Welcome to my site here is something to get started.)
to appear after the login button to the right same line....
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 500 total points
ID: 20408307
Something like this?
YOu can place the echo anywhere you like :)
<?php
$link="http://www.website.com";
if(!isset($_POST['agree']) && isset($_POST["is_submit"]) && $_POST["is_submit"]==1)
{
$error_text = "Please agree to the terms, it is all I am asking!";
}
else if(isset($_POST['agree']) && $_POST['agree']=="ON")
{
header("location:$link");
}
?>
 
<html>
 
<head>
<title>site</title>
</head>
 
<body>
 
Welcome to my site here is something to get started.
<form action="agree.php" method=POST>
 
<textarea name="textfield" rows="5" cols="25" wrap="virtual" readonly onFocus="this.blur();">OK so here are my terms and conditions.</textarea>
 
      <p><input type="checkbox" name="agree" value="ON">I Agree
      <input type=submit value="Login" style="float: left"><?php echo $error_text; ?>
      <input type="hidden" name="is_submit" value="1">
      </p>
      &nbsp;</form>
 
</body>
 
</html>

Open in new window

0
 
LVL 28

Expert Comment

by:gamebits
ID: 20408316
You can go in and out of php as you wish, wherever you want an echo statement to appear in an html document just open a php tag do your php script close the php tag.

ex.
some html
Bla
Bla
Bla
BlaBlaBlaBlaBla <?php echo "some php"; ?> back to html BlaBlaBlaBlaBla
BlaBlaBla
Bla
0
 
LVL 2

Author Closing Comment

by:bcmeyer1983
ID: 31412761
wow, that simple. thanks for filling me in
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20408425
Glad to help :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question