Jump to content

PHP with HTML


thebigchief

Recommended Posts

Can someone convert what I have here so that I can use it as echo "code below";

 

I have tried all sorts and it just does not seem to work:

 

<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></td><td><?php echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></td><td><?php echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <?php if($form->value("remember") != ""){ echo "checked"; } ?>
<font size="2">Remember me next time     
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
</table>
</form>

Link to comment
Share on other sites

did you try the heredoc??

another way could be to do something like this

 

<?php if (1==1){ ?>

<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></td><td><?php echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></td><td><?php echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <?php if($form->value("remember") != ""){ echo "checked"; } ?>
<font size="2">Remember me next time     
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
</table>
</form>


<?php } ?>

Link to comment
Share on other sites

XD looking is not trying.

 

heredoc just is a nice way to but crap loads of html without using all echoes and stuff.

exactly as the example on the page i linked shows:

<?php
    
$name = "Max";

$str = <<<DEMO

      Hello $name! <br/>
      This is a 
      demo message
      with heredoc.
DEMO; //make sure this mark touched the sideline!!!
      
echo $str;

?>

 

Link to comment
Share on other sites

The output on the page now shows this:

 

Username: <input type="text" name="user" maxlength="30" value="

 

Then completely blank  :confused:

 

I bet that's because your using <?php  and ?> inside the heredoc. just use $var instead of <?php echo $var; ?>

 

-edit: i haven't tested it, but i would also put the conditional stuf above the heredoc and only use plain variables in the herdoc itself, i am pretty sure the -> signs won't work inside it. Well i assume you know how to do that

Link to comment
Share on other sites

I am pretty sure if you read what i wrote above here you should have been able to do so but it seems comfort is more appreciated. XD

by the way what editor are you using your code is missing loads of endtags!. download netbeans and use it!!

 

I would appreciate it if you would put some effort in this yourself.

anyways here is a ready made code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>lazy people's form</title>
</head>
    <body>
      <h1>lazy people never get rich</h1>

<?php 
//define your conditional variables above the heredoc (exactly as i told!)

$user = 'user';
$pass = 'pasword';
$your_error_user = 'lalala';
$your_error_user = 'lalalalalala';
$your_conditional_value = 'whatever'; // you can put an if-statement infront of this

//starting of your heredoc (exactly as i told!!)
$str = <<<DEMO

      <form action="process.php" method="POST">
        <table align="left" border="0" cellspacing="0" cellpadding="3">
            <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="$user" /></td><td>$your_error_user</td></tr>
            <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="$pass" /></td><td>$your_error_pass</td></tr>
            <tr><td colspan="2" align="left"><input type="checkbox" name="remember" value="$your_conditional_value" />
            <font size="2" />Remember me next time     
            <input type="hidden" name="sublogin" value="1" />
            <input type="submit" value="Login" /></td></tr>
            <tr><td colspan="2" align="left" ><br /><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
        </table>
      </form>
      
DEMO;

//I hope next time you read more carefuly in the comments!!
?>
    </body>
</html>

 

 

 

 

Link to comment
Share on other sites

no problemo  ;)

 

I can really recommend netbeans, I use it in combination with xampp (10 min. easy setup) and it works like a charm.

I also noticed you use <br> it should be <br /> and don't forget the  /> at the end of your input fields.

Just compare your code and mine and you see what I mean.

best of luck!

Link to comment
Share on other sites

maybe have a look in this

http://24ways.org/2005/transitional-vs-strict-markup

just a quote from that article:

Go Strict and move all presentation to CSS

 

Something that can be helpful when doing the transition from Transitional to Strict DOCTYPEs is to focus on what each element of the page you are working on is instead of how you want it to look.

 

Worry about looks later and get the structure and semantics right first.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.