Welcome to WebmasterWorld Guest from 23.22.182.29

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Preventing Page from reloading

i dont want to lose entered data into form when clicking submit button

     
9:36 am on Apr 3, 2014 (gmt 0)

New User

joined:Apr 3, 2014
posts: 1
votes: 0


<?php session_start();
include("conn.php");
$arr=array();
if(isset($_REQUEST['submit']))
{
if(empty($_POST['name']))
{
$arr['name']="Enter Full Name";
}



if(empty($_POST['email']))
{
$arr['email']="Enter Your Email";
}
elseif(!preg_match("/^[a-zA-Z.+-_*0-9]+@[a-zA-Z0-9]+.[a-zA-Z]*$/",$_POST['email']))
{
$arr['email']="Enter Valid Email ";
}

if(empty($_POST['mobile']))
{
$arr['mobile']="Enter Your Mobile No.";
}
elseif(!preg_match("/^[0-9]*$/",$_POST['mobile']))
{
$arr['mobile']="Enter Valid Mobile No.";
}

if($_POST['course']=='* Select Course')
{
$arr['course']="Select Course";
}

if($_POST['schedule']=='* Select Schedule')
{
$arr['schedule']="Select Schedule";
}

if(empty($arr))
{
$que="insert into registration(name,email,mobile,course,schedule,address,date)
values('".$_POST['name']."','".$_POST['email']."',
'".$_POST['mobile']."','".$_POST['course']."','".$_POST['schedule']."','".$_POST['address']."',now())";
$hk=mysql_query($que)or die(mysql_error());
if($hk)
{
echo '<script>alert("You Have Been Registered.We Will Come Back To You Soon!");</script>';
echo '<script>window.location="online_registration.php";</script>';
}
}
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<title>Summer Training |winter Training |Industrial Training |Noida |Chandigarh</title>
<meta charset="utf-8">
<link rel="icon" href="images/exuberant_ico.ico" type="image/x-icon">
<link rel="shortcut icon" href="images/exuberant_ico.ico" type="image/x-icon" />
<meta name="description" content="Your description">
<meta name="keywords" content="Your keywords">
<meta name="author" content="NESPL" >
<meta name = "format-detection" content = "telephone=no" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!--CSS-->
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/responsive.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/camera.css">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/touchTouch.css">
<!--JS-->
<script src="js/jquery.js"></script>
<script src="js/jquery-migrate-1.1.1.js"></script>
<script src="js/superfish.js"></script>
<script src="js/jquery.mobilemenu.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="js/forms.js"></script>
<script src="js/jquery.easing.1.3.js"></script>
<script src="js/camera.js"></script>
<script src="js/jquery.ui.totop.js"></script>
<script>
$(document).ready(function(){
jQuery('.camera_wrap').camera();
});
</script>
<script src="js/touchTouch.jquery.js"></script>
<script>
$(window).load(function() {
// Initialize the gallery
$('.thumb-pad3 figure a').touchTouch();
});
</script>

<!--[if (gt IE 9)|!(IE)]><!-->
<script type="text/javascript" src="js/jquery.mobile.customized.min.js"></script>

<!-- Scroller -->
<script src="js/images-scrollar.js" type="text/javascript"></script>
<script type="text/javascript">
(function($) {
$(function() { //on DOM ready
$("#scroller").simplyScroll({
autoMode: 'loop'
});
});
})(jQuery);
</script>
<!-- Scroller -->
<!--<![endif]-->
<!--[if lt IE 8]>
<div style='text-align:center'><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="http://www.theie6countdown.com/img/upgrade.jpg"border="0"alt=""/></a></div>
<![endif]-->
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/ie.css">
<link rel="stylesheet" href="css/docs.css">
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="global">
<!--header-->
<header>
<div class="main">
<div class="gradient">
<div class="container" style="padding-bottom:10px">
<article>
<div class="navbar navbar_ clearfix">
<div class="navbar-inner">
<div class="clearfix">
<div class="nav-collapse nav-collapse_">
<ul class="nav sf-menu clearfix">
<li class="active"><a href="index.html" style="background:#1295d5;">Home</a></li>
<li class="sub-menu"><a style="background:#1295d5;" href="aboutus.html">About Us</a>

</li>
<li class="sub-menu"><a style="background:#1295d5;;" href="javascript:;">Training</a>
<ul class="sub-menu2";>
<li><a href="javascript:;">Wireless & Telecom</a>
<ul class="sub-menu2";>
<li><a href="javascript:;">Wirelss Engineer-Advanced</a></li>
<li><a href="javascript:;">Wireless Engineer-Masters</a></li>
<li><a href="javascript:;">Wireless Engineer-Expert</a></li>
<li><a href="javascript:;">Transmission Engineer-Advanced</a></li>
<li><a href="javascript:;">Transmission Engineer-Masters</a></li>
<li><a href="javascript:;">Transmission Engineer-Expert</a></li>
<li><a href="javascript:;">Telecom Engineer</a></li>
</ul>
</li>
<li><a href="javascript:;">Mobile Applications</a>
<ul class="sub-menu2";>
<li><a href="javascript:;">Android</a></li>
<li><a href="javascript:;">Iphone</a></li>
<li><a href="javascript:;">Android + Iphone</a></li>
<li><a href="javascript:;">Advance Android + Iphone</a></li>

</ul>
</li>
</ul>
</li>
<li class="sub-menu"><a style="background:#1295d5;" href="whyus.html">Why Us</a>
</li>
<li class="sub-menu"><a style="background:#075192;" href="online_registration.php">Online Registration</a>

</li>
<li><a style="background:#1295d5;" href="contactus.php">Contact Us</a></li>
</ul>
</div>
<ul class="follow_icon">
<li><a href="javascript:;"><img src="img/follow_icon1.png" alt=""></a></li>
<li><a href="javascript:;"><img src="img/follow_icon2.png" alt=""></a></li>
<li><a href="javascript:;"><img src="img/follow_icon3.png" alt=""></a></li>
<li><a href="javascript:;"><img src="img/follow_icon4.png" alt=""></a></li>
</ul>
</div>
</div>
</div>
<h1 class="brand"><a href="index.html"><img src="img/nexg_newlogo.jpg" alt=""></a></h1>

</article>

</div>

</div>
</div>
</header>
<div class="main">
<section class="container padTop" style=" padding-top:20px">
<div class="row">
<article class="span9 slider pull-right">
<img src="img/registration.jpg" style="height:368px;">
</article>

<article class="span3 list1-box pull-left">
<ul class="list1">
<li><a href="javascript:;">Admission</a></li>
<li><a href="javascript:;">Online Tutorial</a></li>
<li><a href="javascript:;">Placement Cell</a></li>
<li><a href="javascript:;">Our Team</a></li>
<li><a href="javascript:;">Gallery</a></li>
<li><a href="javascript:;">Careers</a></li>
<li><a href="javascript:;">Clientele</a></li>
<li><a href="javascript:;">Testimonials</a></li>
</ul>
</article>
</div>
</section>
</div>
<div class="main">
<div class="gradient1">
<section class="container">
<div class="row">
<article class="span12 margBot6">
<div class="row" style="margin-top:20px;">
<div class="span6 support-box">
<h3>Online Registration Form</h3>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
<table>
<tr><td style="padding-top:10px; padding-left:260px;"><input type="text" name="name" placeholder="* Enter Full Name"><span style="color:red;font-size:10px;"><?php echo @$arr['name'];?></span></td></tr>
<tr><td style="padding-left:260px;"><input type="text" name="email" placeholder="* Enter Your Email"><span style="color:red;font-size:10px;"><?php echo @$arr['email'];?></span></td></tr>

<tr><td style="padding-left:260px;"><textarea name="address" rows="2" placeholder="Enter your Full Address" ></textarea></td></tr>
</table> </div>
<div class="span4 support-box">
<table>

<tr><td style="padding-top:37px;"><input type="text" name="mobile" placeholder="* Enter Your Mobile No."><span style="color:red;font-size:10px;"><?php echo @$arr['mobile'];?></span></td></tr>
<tr><td><select name="schedule">
<option>* Select Schedule</option>
<option>Weekdays</option>
<option>Weekends</option>
</select><span style="color:red;font-size:10px;"><?php echo @$arr['schedule'];?></span></td></tr>
<tr><td><select name="course">
<option>* Select Course</option>
<option>Wireless Engineer-Advanced</option>
<option>Wireless Engineer-Masters</option>
<option>Wireless Engineer-Expert</option>
<option>Transmission Engineer-Advanced</option>
<option>Transmission Engineer-Masters</option>
<option>Transmission Engineer-Expert</option>
<option>Telecom Engineer</option>
<option>Android</option>
<option>Iphone</option>
<option>Android + Iphone</option>
<option>Advance Android + Iphone</option>
</select><span style="color:red;font-size:10px;"><?php echo @$arr['course'];?></span></td></tr>
</table>
<input type="submit" name="submit" value="Submit" style="width:100px;">
</form> <br><br>
<p>* Required Fields</p>
</div>


</div>
</article>
</div>
</section>
</div>
</div>
<div style="clear:both"></div>
<!--footer-->
<div class="footer1">
<footer>
<div class="main">
<div class="container">
<div class="row">
<article class="span4">
<p>Nex-G|Ict &copy; 2014. <a href="javascript:;">Privacy Policy</a></p><br/>
<p>Designed & Developed By <a href="#">Nex-G Exuberant Solutions Pvt. Ltd.</a></p>
</article>
<article class="span8">
<ul class="list-footer">
<li><a href="javascript:;">Home</a></li>
<li><a href="javascript:;">About Us</a></li>
<li><a href="javascript:;">Programmes</a></li>
<li><a href="javascript:;">Enviroment</a></li>
<li><a href="javascript:;">Partners</a></li>
<li><a href="javascript:;">Contact us</a></li>
</ul>


</article>
<br/><br/>
<article class="span13">

<a href="#"><img src="img/f.png" class="img1";></a>
<a href="#"><img src="img/t.png" class="img2";></a>
<a href="#"><img src="img/gplus.png" class="img3";></a>
<a href="#"><img src="img/r.png" class="img4";></a>
<a href="#"><img src="img/tb.png" class="img5";></a>

</article>

</div>
<!-- {%FOOTER_LINK} -->
</div>
</div>
</footer>
</div>
3:07 pm on Apr 3, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


When the page loads and you generate your form you should be outputting the (submitted) values at that stage.
3:34 am on Apr 5, 2014 (gmt 0)

Administrator from US 

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
posts:14624
votes: 88


For instance, things like this:

<input type="text" name="name" placeholder="* Enter Full Name">

Should be something like:

<input type="text" name="name" placeholder="* Enter Full Name" value="<?=$_POST['name']?>">

or...

<textarea name="address" rows="2" placeholder="Enter your Full Address" ></textarea>

Should be:

<textarea name="address" rows="2" placeholder="Enter your Full Address" ><?=$_POST['address']?></textarea>

Not exactly how I'd do it, but you should get the general idea.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members