How can I output the resulting echo from my php to the main html?
heres my code:
what I want is when the I submit , the resulting echo will be posted in the <p id="alert" name="alert"></p> of the main html
HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>REGISTER</title>
<link rel="stylesheet" type="text/css" href="login.css" title="style" media="screen" />
</head>
<body>
<div id="wrap" name="wrap">
<div class="idea"><img src="images/message.png" alt=""/>
<p id="alert" name="alert">Please enter your details below to Login!</p>
</div>
<div class="block" id="block" name="block">
<form action="login.php" name="form" method="post">
<div class="left"></div>
<div class="right">
<div class="div-row"><input type="text" id="username" name="name" value="" /></div>
<div class="div-row"><input type="password" id="password" name="pass" value="" /></div>
<div class="send-row">
<input type="submit" id="reg" value="" name="submit "/>
<input type="submit" id="delete" value="" name="delete" />
</div>
</div>
</form>
</div>
</div>
</body>
</html>
PHP:
<?php
$error='';
session_start();
function check($usercheck)
{
if(empty($_SESSION['user']) || empty($_SESSION['pass']))
{
return;
}
else
{
foreach($_SESSION['user'] as $value)
{
if($value == $_POST['name'])
{
return true;
}
else
return false;
}
}
}
if(isset($_POST['submit']))
{
if(check($_POST['name']))
{
echo "Username already exist!";
}
elseif($_POST['name'] == null || $_POST['pass'] == null)
{
echo "Please insert valid username and password";
}
else
{
echo "Account successfully registered!";
$_SESSION['user'][] = strtolower($_POST['name']);
$_SESSION['pass'][] = strtolower($_POST['pass']);
}
}
if(isset($_POST['view']))
{
foreach($_SESSION['user'] as $value)
{
echo $value;
}
foreach($_SESSION['pass'] as $value)
{
echo $value;
}
}
if(isset($_POST['delete']))
{
session_destroy();
}
?>