Become PHP Expert in 30 days
FreeMarriage.com - Free Online Matrimonial
FlashWebHost.com - Professional Web Hosting, Designing.
DAY 10 PHP PROGRAMMING
http://php.flashwebhost.com/ramesh/day-10/cookie_2.php
PHP Code:
<?php
if(isset($_COOKIE['userName'])) {
echo '<h2 style="color:blue">Hi ' . $_COOKIE[userName] . '!, welcome back.</h2>';
exit;
}
if(isset($_POST['userName']) && strlen($_POST['userName']) > 3) {
setcookie('userName', $_POST['userName'], time() + 3600);
echo '<h3 style="color:green">You may close the browser and re-login, I will remember your Name. </h3>';
} else {
echo '
<html>
<body style="background-color:#000">
<form method="POST" action="">
<input type="text" name="userName">
<button type="submit">Click here</button>
</body>
</html>
';
}
Can we start php using '<?' only instead of '<?php'.
I had seen this post in which the code working and executing successfully.
DAY 10 PHP PROGRAMMING
http://php.flashwebhost.com/tom/day_10_ex_1.php
PHP Code:
<?php
if (isset($_COOKIE['clientName'])) {
echo 'Hello ' . $_COOKIE['clientName'] . ' Welcome to Our WebSite';exit;
}
if (isset($_POST['clientName']) && strlen($_POST['clientName']) > 3 ){
setcookie('clientName', $_POST['clientName'], time()+3600);
echo ' Cookie Set. Close the browser. Revisit this page, I will remember your name';
} else {
echo'
What is Your Name?
<form method="POST" action=""><input type="text" name="clientName"><button type="submit" name="whatever">Enter</button></form>
';
}
Bookmarks