Reaper0167 Posted January 4, 2009 Share Posted January 4, 2009 I transferred the code exactly from the book so I could get a look at what they were showing...But the divs show up where the errors are suppose to go. Anyone know why? Here is what I got when I used the code from the book. http://www.mylahstone.com and here is the code. <?php //File Name: reg_log.inc include ("functions.inc"); ?> <html> <head> <title>Member Login</title> <style type='text/css'> <!-- label { font-weight: bold; float: left; width: 27%; margin-right: .5em; text-align: right; } legend { font-weight: bold; font-size: 1.2em; margin-bottom: .5em; } #wrapper { margin: 0; padding: 0; } #login { position: absolute; left: 0; width: 39%; padding: 1em 0; } #reg { position: absolute; left: 40%; width: 60%; padding: 1em 0; } #field {padding-bottom: .5em;} .errors { font-weight: bold; font-style: italic; font-size: 90%; color: red; margin-top: 0; } --> </style> </head> <body style="margin: 0"> <?php $fields_1 = array("fusername" => "User Name", "fpassword" => "Password"); $fields_2 = array("user_name" => "User Name", "password" => "Password", "email" => "Email", "first_name" => "First Name", "last_name" => "Last Name", "street" => "Street", "city" => "City", "state" => "State", "zip" => "Zip", "phone" => "Phone", "fax" => "Fax"); ?> <div id="wrapper"> <div id="login"> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <fieldset style='border: 2px solid #000000'> <legend>Login Form</legend> <?php if (isset($message_1)) { echo "<p class='errors'>$message_1</p>\n"; } foreach ($fields_1 as $field => $value) { if (preg_match("/pass/i", $field)) $type = "password"; else $type = "text"; echo "<div id='field'> <label for='$field'>$value</label> <input id='$field' name='$field' type='$type' value='" . @$$field ."' size='20' maxlength='50' /> </div>\n"; } ?> <input type="submit" name="Button" style='margin-left: 45%; margin-bottom: .5em' value=" Login " /> </fieldset> </form> <p style='text-align: center; margin: 1em'> If you alreay have an account, log in.</p> <p style='text-align: center; margin: 1em'> If you don't have an account, register now.</p> </div> <div id="reg"> <form action=<?php echo $_SERVER['PHP_SELF'] ?> method="POST"> <fieldset style='border: 2px solid #000000'> <legend>Form Registration</legend> <?php if (isset($message_2)) { echo "<p class='errors'>$message_2</p>\n"; } foreach ($fields_2 as $field => $value) { if ($field == "state") { echo "<div id='field'><label for='$field'>$value</label><select name='state' id='state'>"; $stateName=getStateName(); $stateCode=getStateCode(); for ($n=1;$n<=50;$n++) { $state=$stateName[$n]; $scode=$stateCode{$n}; echo "<option value='$scode'"; if ($scode== "AL") echo "selected"; echo ">$state</option>\n"; } echo "</select></div>"; } else { if(preg_match(" / pass / i",$field)) $type = "password"; else $type = "text"; echo " < div id = 'field' > <label for = '$field'> $value </label> <input id = '$field'name = '$field'type = '$type'value = '".@$$field."'size = '40'maxlength = '65' / > < div > \n"; } } ?> <input type="submit" name="Button" style='margin-left: 45%; margin-bottom: .5em' value="Register"> </fieldset> </form> </div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/139464-solved-php-and-mysql-for-dummies-example-loginreg-form-with-problems/ Share on other sites More sharing options...
btherl Posted January 5, 2009 Share Posted January 5, 2009 Try removing the extra spaces in here: echo " < div id = 'field' > <label for = '$field'> $value </label> <input id = '$field'name = '$field'type = '$type'value = '".@$$field."'size = '40'maxlength = '65' / > < div > \n"; So there is no space between the "<" and the "div", for example. Link to comment https://forums.phpfreaks.com/topic/139464-solved-php-and-mysql-for-dummies-example-loginreg-form-with-problems/#findComment-729631 Share on other sites More sharing options...
Reaper0167 Posted January 5, 2009 Author Share Posted January 5, 2009 that worked,, thank you Link to comment https://forums.phpfreaks.com/topic/139464-solved-php-and-mysql-for-dummies-example-loginreg-form-with-problems/#findComment-729685 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.