Solved

PHP echo statement location within html

Posted on 2007-12-04
5
2,352 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now