Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old 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 snelll is on a distinguished road
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
snelll is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 joonty is on a distinguished road
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:

Code:
<?php
...
some code
...
?>
Javascript runs in a users browser ("client-side") and PHP runs on the web server before it reaches the user ("server-side").

j
__________________
joncairns.com
joonty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 snelll is on a distinguished road
Re: PHP and HTML/XHTML?

so ermm u can use all the html stuff in a php file aswell as the actual php?
snelll is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 19th, 2008, 04:27 AM   #4
WebForumz Admin Badge
SuperMember
 
Marc's Avatar
 

Join Date: Apr 2007
Location: Scotland, UK
Posts: 2,086
Thanks: 2
Thanked 23 Times in 23 Posts
Rep Altering Power: 89 Marc is just really nice Marc is just really nice Marc is just really nice Marc is just really nice
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.
__________________
Regards
Marc
Administrator - Webforumz.com

Web Design and Development Blog - Marc Fraser

Last edited by Marc; October 19th, 2008 at 04:33 AM..
Marc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 snelll is on a distinguished road
Re: PHP and HTML/XHTML?

Ermm could i see an example of what a php page source would look like?
Like the whole thing
snelll is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 19th, 2008, 08:01 AM   #6
WebForumz Admin Badge
SuperMember
 
Marc's Avatar
 

Join Date: Apr 2007
Location: Scotland, UK
Posts: 2,086
Thanks: 2
Thanked 23 Times in 23 Posts
Rep Altering Power: 89 Marc is just really nice Marc is just really nice Marc is just really nice Marc is just really nice
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 != ) { 

        
// 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>&nbsp;</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>&nbsp;</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.
__________________
Regards
Marc
Administrator - Webforumz.com

Web Design and Development Blog - Marc Fraser
Marc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 snelll is on a distinguished road
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?
snelll is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 joonty is on a distinguished road
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, "?>".
__________________
joncairns.com
joonty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 19th, 2008, 02:25 PM   #9
Most Reputable Member
 

Join Date: May 2007
Location: Cornwall, England
Posts: 1,421
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Rep Altering Power: 0 Jack Franklin will become famous soon enough
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!
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 snelll is on a distinguished road
Re: PHP and HTML/XHTML?

Yh thanks, i think i understand now
snelll is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


Search Engine Optimization by vBSEO 3.2.0 RC8