How to move text output of php in html -
i have php code block related account login logout etc. however, when log in without valid password echos "please enter valid username/password" however, when text appear, covered html scripts, dont know if can position it? or have convert html scripts, please enligten me thanx x
this output coming
<!d0ctype html> <html> <head> <style> #lions { position:absolute; top:15px; left:1200px; z-index:9; } </style> </head> </html> <?php if (isset($_post['username'])&&isset($_post['password'])){ $username = $_post['username']; $password = $_post['password']; $password_hash = md5($password); if(!empty($username)&&!empty($password)){ $query = "select `id` `users` `username`='".mysql_real_escape_string($username)."' , `password`='".mysql_real_escape_string($password_hash)."'"; if ($query_run = @mysql_query($query)){ $query_num_rows = mysql_num_rows($query_run); if($query_num_rows == 0){ echo 'invalid username/password!'; }else if ($query_num_rows == 1){ $user_id = mysql_result($query_run, 0 ,'id'); $_session['user_id'] = $user_id; header('location: index.php'); } } }else{ echo 'you must enter username/password!'; } } ?> <div id="lions"> <form action ="<?php echo $current_file; ?>" method="post"> username: <input type="text" name="username"> password:<input type="password" name="password"> <input type ="submit" value="log in"> </form> </div> main page <!d0ctype html> <html> <head> <title> volunnear </title> <meta charset = "utf-8"> <link rel = "stylesheet" href ="stylex.css"> <link href='http://fonts.googleapis.com/css?family=lobster' rel='stylesheet' type='text/css'> <?php require 'core.inc.php'; require 'connect.inc.php'; if(loggedin()){ $fname= getuserfield('firstname'); $sname= getuserfield('surname'); echo 'you\'re logged in '. $fname.' '.$sname. '<a href="logout.php"> log out</a>'; }else{ include 'loginform.inc.php'; } ?> </head> <body> <h1 id="id1"> <span class="span1">volun</span><span class="spanx">near</span> </h1> <div id="nav"> <div id="nav_wrapper"> <ul> <li><a href="#">volunteering leaderboard</a> </li> <li><a href="#">hour tracker</a> </li> <li><a href="#">non-profits </a> </li> <li><a href="#">contact us</a> <ul> <li><a href="#"> here</a> </li> <li><a href="#"> contact form</a> </li> <li><a href="#"> suggestion form</a> </li> </ul> </li> <li><a href="#">hour log</a> <ul> <li><a href="#">your hours</a> </li> <li><a href="#">ontario regulations</a> </li> </ul> </li> </li> </li> </ul> </body> </html>
echo output has been placed in code, if php script calling echo before html output, echoed string appear above html.
if want message within html, should, should instead place message in variable, , within html, call echo wherever message appear.
but @andre stated, without actual code, it's hard give clear example.
<?php $my_message = 'please enter valid username/password'; ?> <html> <head></head> <body> <div id="error_message"> <?= $my_message; ?> </div> </body> </html>
something along lines, super basic example.
Comments
Post a Comment