|
|
 |
October 18th, 2008, 07:01 PM
|
#1
|
|
Reputable Member
Join Date: Feb 2008
Location: chelmsford,essex
Posts: 109
Thanks: 24
Thanked 1 Time in 1 Post
Rep Altering Power: 0
|
PHP and HTML/XHTML?
This might be a nOOb question,
In PHP do u have the HTML and the php just fits in like javascript(<script... ),
Please reply 
|
|
|
October 18th, 2008, 09:30 PM
|
#2
|
|
WebForumz Member
Join Date: Jul 2008
Location: Worcester
Posts: 62
Thanks: 0
Thanked 9 Times in 8 Posts
Rep Altering Power: 0
|
Re: PHP and HTML/XHTML?
Yes, in a sense, although Javascript can be part of an html extension file (e.g. mypage. html), whereas PHP script can only run on a php file (e.g. mypage. php). However, if an html extension is changed to a php extension the way that the html is read remains the same. PHP code is written in the following format:
Javascript runs in a users browser ("client-side") and PHP runs on the web server before it reaches the user ("server-side").
j
|
|
|
October 18th, 2008, 09:31 PM
|
#3
|
|
Reputable Member
Join Date: Feb 2008
Location: chelmsford,essex
Posts: 109
Thanks: 24
Thanked 1 Time in 1 Post
Rep Altering Power: 0
|
Re: PHP and HTML/XHTML?
so ermm u can use all the html stuff in a php file aswell as the actual php?
|
|
|
October 19th, 2008, 04:27 AM
|
#4
|
SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 2,086
Thanks: 2
Thanked 23 Times in 23 Posts
|
Re: PHP and HTML/XHTML?
If you want to use some HTML, you need to PRINT it in PHP so like so:
Code:
<?php print "<head>"; print "<body>"; ?>
PHP is run first and HTML next - all outputs from PHP are sent to the HTML engine.
Last edited by Marc; October 19th, 2008 at 04:33 AM..
|
|
|
October 19th, 2008, 07:27 AM
|
#5
|
|
Reputable Member
Join Date: Feb 2008
Location: chelmsford,essex
Posts: 109
Thanks: 24
Thanked 1 Time in 1 Post
Rep Altering Power: 0
|
Re: PHP and HTML/XHTML?
Ermm could i see an example of what a php page source would look like?
Like the whole thing 
|
|
|
October 19th, 2008, 08:01 AM
|
#6
|
SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 2,086
Thanks: 2
Thanked 23 Times in 23 Posts
|
Re: PHP and HTML/XHTML?
Code:
<?php include 'dbc.php';
$user_email = mysql_real_escape_string($_POST['email']);
if ($_POST['Submit']=='Login') { $md5pass = md5($_POST['pwd']); $sql = "SELECT id,user_email FROM users WHERE user_email = '$user_email' AND user_pwd = '$md5pass' AND user_activated='1'"; $result = mysql_query($sql) or die (mysql_error()); $num = mysql_num_rows($result);
if ( $num != 0 ) {
// A matching row was found - the user is authenticated. session_start(); list($user_id,$user_email) = mysql_fetch_row($result); // this sets variables in the session $_SESSION['user']= $user_email; if (isset($_GET['ret']) && !empty($_GET['ret'])) { header("Location: $_GET[ret]"); } else { header("Location: myaccount.php"); } //echo "Logged in..."; exit(); }
header("Location: login.php?msg=Invalid Login"); //echo "Error:"; exit(); }
?>
<link href="styles.css" rel="stylesheet" type="text/css">
<?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
<p> </p><table width="40%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#d5e8f9" class="mnuheader" > <div align="center"><font size="5"><strong>Login Members</strong></font></div></td> </tr> <tr> <td bgcolor="#e5ecf9" class="mnubody"><form name="form1" method="post" action=""> <p> </p> <p align="center">Your Email <input name="email" type="text" id="email"> </p> <p align="center"> Password: <input name="pwd" type="password" id="pwd"> </p> <p align="center"> <input type="submit" name="Submit" value="Login"> </p> <p align="center"><a href="register.php">Register</a> | <a href="forgot.php">Forgot</a></p> </form></td> </tr> </table>
The above is an example of a Login Script.
|
|
|
October 19th, 2008, 08:03 AM
|
#7
|
|
Reputable Member
Join Date: Feb 2008
Location: chelmsford,essex
Posts: 109
Thanks: 24
Thanked 1 Time in 1 Post
Rep Altering Power: 0
|
Re: PHP and HTML/XHTML?
so there is html and php all mixed in it?
and would there be the <body> <head> and < html> tags?
|
|
|
October 19th, 2008, 12:02 PM
|
#8
|
|
WebForumz Member
Join Date: Jul 2008
Location: Worcester
Posts: 62
Thanks: 0
Thanked 9 Times in 8 Posts
Rep Altering Power: 0
|
Re: PHP and HTML/XHTML?
Yeh that's what I was trying to say, PHP files can contain html tags like <body>, <head>, etc. and it will be read like html. Then as soon as "<? php" is written, it is read like PHP code until the closing tag, "?>".
|
|
|
October 19th, 2008, 02:25 PM
|
#9
|
|
Most Reputable Member
Join Date: May 2007
Location: Cornwall, England
Posts: 1,421
Thanks: 18
Thanked 14 Times in 14 Posts
Rep Altering Power: 0
|
Re: PHP and HTML/XHTML?
You could have a normal div and text like this:
Code:
<div>
<h1>Blah blah</h1>
<p>SOme text about our company</p>
</div>
And then mix in some PHP:
Code:
<div>
<h1>Blah blah <?php echo "Hi!"; ?></h1>
<p>SOme text about our company</p>
</div>
__________________
Yours is the Earth and everything that's in it
And - which is more - you'll be a Man my son!
|
|
|
October 19th, 2008, 02:37 PM
|
#10
|
|
Reputable Member
Join Date: Feb 2008
Location: chelmsford,essex
Posts: 109
Thanks: 24
Thanked 1 Time in 1 Post
Rep Altering Power: 0
|
Re: PHP and HTML/XHTML?
Yh thanks, i think i understand now
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
|
[SOLVED] HTML or XHTML
|
marSoul |
HTML, XHTML and CSS |
18 |
December 23rd, 2007 06:53 AM |
|
XHTML V2 vs. HTML V5
|
c010depunkk |
The Café |
1 |
December 17th, 2007 05:23 AM |
|
xhtml , html
|
leckenby15 |
HTML, XHTML and CSS |
3 |
May 30th, 2007 11:05 AM |
|
Converting from HTML to XHTML
|
Aaron1988 |
HTML, XHTML and CSS |
1 |
December 4th, 2006 12:09 PM |
|
help with converting HTML to XHTML
|
sing2trees |
HTML, XHTML and CSS |
4 |
September 20th, 2006 12:35 AM |
|