thebigchief Posted October 20, 2010 Share Posted October 20, 2010 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 https://forums.phpfreaks.com/topic/216361-php-with-html/ Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 i don't really understand what you mean. Do you want to echo out that whole bit like a string value or something? heredocs could be worth looking in: http://www.phpf1.com/tutorial/php-heredoc-syntax.html Link to comment https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124327 Share on other sites More sharing options...
thebigchief Posted October 20, 2010 Author Share Posted October 20, 2010 i don't really understand what you mean. Do you want to echo out that whole bit like a string value or something? heredocs could be worth looking in: http://www.phpf1.com/tutorial/php-heredoc-syntax.html Yep, that's pretty much what I wanna do. I need the above to be echoed out but I seem to get the " and the ' all over the place. Link to comment https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124328 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 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 https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124330 Share on other sites More sharing options...
thebigchief Posted October 20, 2010 Author Share Posted October 20, 2010 did you try the heredoc?? Just looked at it there but I dont understand how it would work with the other php parts I have in there. Link to comment https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124331 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 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 https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124333 Share on other sites More sharing options...
thebigchief Posted October 20, 2010 Author Share Posted October 20, 2010 The output on the page now shows this: Username: <input type="text" name="user" maxlength="30" value=" Then completely blank Link to comment https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124334 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 The output on the page now shows this: Username: <input type="text" name="user" maxlength="30" value=" Then completely blank 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 https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124335 Share on other sites More sharing options...
thebigchief Posted October 20, 2010 Author Share Posted October 20, 2010 I've played about with the heredoc and cant get it to work either.... I either get a blank output or it shows part the code on the page Since I can work out your decimal name can you help me a little more Link to comment https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124352 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 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 https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124365 Share on other sites More sharing options...
thebigchief Posted October 20, 2010 Author Share Posted October 20, 2010 Thank you sooooo much, I know it doesn't seem it but I honestly did try. I am using Notepad ++ which has not thrown anything up as yet. Link to comment https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124372 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 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 https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124436 Share on other sites More sharing options...
elmas156 Posted October 20, 2010 Share Posted October 20, 2010 just a quick question... what does it matter if <br> is used instead of <br />? Just wondering because I have been using a lot of <br> instead of <br />. Link to comment https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124453 Share on other sites More sharing options...
Pikachu2000 Posted October 20, 2010 Share Posted October 20, 2010 It depends whether your doctype is HTML or XHTML as to which one you'd use. XML/XHTML require that all tags be explicitly closed, so they use the <br /> tag format. Link to comment https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124459 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 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 https://forums.phpfreaks.com/topic/216361-php-with-html/#findComment-1124461 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.