html form,db submission,empty data on refresh or back - javascript

I have a from submitting data to db,and after entering in to db thank you message comes,everything is in same page.the problem is wheni refresh or go back the same data or empty data is entered in to db. Please help`
<?php
$myServer = "localhost";
$myUser = "root";
$myPass = "";
$myDB = "sample";
$name=$_POST['fname'];
$mobile=$_POST['mobile'];
$email=$_POST['email'];
//connection to the database
$dbhandle = mysql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mysql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//echo "$myDB";
//Insert data into db
mysql_query("INSERT INTO reg(name,mobile,email) values ('$name','$mobile','$email')");
/* echo "$name";
echo "$mobile";
echo "$email"; */
//header("location:thank.html");
?>
<!doctype html>
<html>
<head>
<title>Basic form with validation</title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="all"/>
</head>
<body>
<div style="width:300px; background:#19a3d1;margin:0 auto;height:200px;">
<?php
if(empty($_POST))
{
?>
<form name="myform" id="frm1" action="index.php" method="post" style="margin:0 auto;"onsubmit="return(validate());">
<h1 style="text-align:center">Form</h1>
<div style="display: table; margin:0 auto;">
<div style="display: table-row;">
<div style="display: table-cell;padding:5px;">
<label>Name</label>
</div>
<div style="display: table-cell;">
<input type="text" name="fname" id="fname" placeholder="Name" />
</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell;padding:5px;">
<label>Mobile</label>
</div>
<div>
<input type="text" name="mobile" id="mobile" placeholder="Mobile" />
</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell;padding:5px;">
<label>Email</label>
</div>
<div>
<input type="text" name="email" id="email" placeholder="Email" />
</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell;padding:5px;" ></div>
<div style="display: table-cell;padding:5px;"><input type="submit" value="Submit"></div>
</div>
</div>
</form>
<?php
}
else{
?>
<div id="thank" >
<span style="color:#ff0000;padding:30px;text-align:center;display:block;">Thank you!!</span>
</div>
<?php
}
?>
</div>
<script src="js/main.js"></script>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</body>
</html>`

Give name of your submit button.
Like
<input type="submit" value="Submit" name="btnSubmit">
And Write PHP Code like this :
<?php
......
......
if(isset($_POST['btnSubmit']))
{
Your code....
}
?>
Or
You can use ajax to submit the form data.
http://www.formget.com/submit-form-using-ajax-php-and-jquery/

Related

How to get the success message after clicking on submit button

I have my code where it should show a success message after submitting (click on add) but for some reason this success message is showing all the time even if I don't add anything, it is just showing on the top of the page.the problem is if I removed the message that is below if statement, the message will not show. the action is working fine it is just the success message. Can you please see what is the problem?
Add.php
<?php
include('header.php');
?>
<link rel="stylesheet" href="../../validation/dist/css/bootstrapValidator.css"/>
<script type="text/javascript" src="../../validation/dist/js/bootstrapValidator.js"></script>
<!-- =============================================== -->
<?php
include('../../form.php');
$frm=new formBuilder;
?>
<!-- =============================================== -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Add Coming Soon Movie
</h1>
<?php
if(isset($_SESSION['add']))
{?>
<div class="alert alert-success">
<strong>Success!</strong> News added successfully..
</div>
<?php
}?>
<ol class="breadcrumb">
<li><i class="fa fa-home"></i> Home</li>
<li class="active">Add Coming Soon Movie</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-body">
<form action="process_add_news.php" method="post" enctype="multipart/form-data" id="form1">
<div class="form-group">
<label class="control-label">Movie name</label>
<input type="text" name="name" class="form-control"/>
<?php $frm->validate("name",array("required","label"=>"Movie Name")); // Validating form using form builder written in form.php ?>
</div>
<div class="form-group">
<label class="control-label">Type</label>
<input type="text" name="type" class="form-control">
<?php $frm->validate("type",array("required","label"=>"Type","regexp"=>"text")); // Validating form using form builder written in form.php ?>
</div>
<div class="form-group">
<label class="control-label">Release Date</label>
<input type="date" name="date" class="form-control"/>
<?php $frm->validate("date",array("required","label"=>"Release Date")); // Validating form using form builder written in form.php ?>
</div>
<div class="form-group">
<label class="control-label">Description</label>
<input type="text" name="description" class="form-control">
<?php $frm->validate("description",array("required","label"=>"Description")); // Validating form using form builder written in form.php ?>
</div>
<div class="form-group">
<label class="control-label">Images</label>
<input type="file" name="attachment" class="form-control" placeholder="Images">
<?php $frm->validate("attachment",array("required","label"=>"Image")); // Validating form using form builder written in form.php ?>
</div>
<div class="form-group">
<label class="control-label">Trailer Youtube Link</label>
<input type="text" name="video" class="form-control"/>
<?php $frm->validate("video",array("label"=>"Image","max"=>"500")); // Validating form using form builder written in form.php ?>
</div>
<div class="form-group">
<button class="btn btn-success">Add Movie</button>
</div>
</form>
</div>
<!-- /.box-footer-->
</div>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<?php
include('footer.php');
?>
<script>
<?php $frm->applyvalidations("form1");?>
</script>
processToAdd.php:
<?php
include('../../config.php');
extract($_POST);
$uploaddir = '../Coming-soon/';
$uploadfile = $uploaddir . basename($_FILES['attachment']['name']);
move_uploaded_file($_FILES['attachment']['tmp_name'],$uploadfile);
$flname="Coming-soon/".basename($_FILES["attachment"]["name"]);
mysqli_query($con,"INSERT INTO tbl_news values (NULL,'$name','$type','$date','$description','$flname','$video')");
$_SESSION['add']=1;
header('location:add_movie_news.php');
?>
I try this and found that, you need to start session
You just need to add session_start();
<?php
session_start();
if(isset($_REQUEST['submit_btn']))
{
$name = $_POST["names"];
$_SESSION['add'] = $name;
print_r($_SESSION);
}
?>
<html>
<head>
</head>
<body>
<?php
if(isset($_SESSION['add'])) {
?>
<div class="">
<strong>Success!</strong> News added successfully..
</div>
<?php
}
?>
<form action="" method="POST">
<input type="text" name="names" id="names">
<input type="submit" value="submit" name="submit_btn">
</form>
<script>
</script>
</body>
</html>
It seems like the issue is the line if(isset($_SESSION['add'])). So as long as $_SESSION['add'] is set the you have to see the message. Its either you unset it immediately after the message and reset it again on each button click or if the button you click is named 'submit', just use
if(isset($_POST['add'])){
//output message here
}
I try your code as example and remove validation and extra things
I also redirect Add.php to processToAdd.php and then again redirect processToAdd.php to Add.php
Please have a look and try this.
Hope this will resolve your problem.
Add.php:
<?php
session_start();
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Add Coming Soon Movie
</h1>
<?php
if(isset($_SESSION['add'])) {
?>
<div class="alert alert-success">
<strong>Success!</strong> News added successfully..
</div>
<?php
}
?>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-body">
<form action="processToAdd.php" method="post" enctype="" id="form1">
<div class="form-group">
<label class="control-label">Movie name</label>
<input type="text" name="name" class="form-control"/>
</div>
<div class="form-group">
<button class="btn btn-success" type="submit">Add Movie</button>
</div>
</form>
</div>
<!-- /.box-footer-->
</div>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
processToAdd.php:
<?php
session_start();
extract($_POST);
$_SESSION['add']=1;
header('location:add.php');
?>

Use PHP to display user inputs

What I'm trying to do is to use PHP to display the user inputs on a separate page, but when I process the form none of the input values display. I'm having to use javascript for input validation and that works fine but the PHP page is not working.
Here is my code:
HTML and Javascript
survey.php:
<!DOCTYPE html>
<html>
<head>
<title>Survey Page</title>
<link rel="stylesheet" type="text/css" href="mystylepage.css" />
<script type="text/javascript">
function validate()
{
if (document.information.name.value == "" )
{
alert("Please provide your name!" );
document.information.value.focus();
return false;
}
if (document.information.email.value == "")
{
alert("Please provide an email!");
document.information.value.focus();
return false;
}
if (document.information.major.value == false)
{
alert("Please enter your major");
document.information.value.focus();
return false;
}
return true;
}
</script>
</head>
<div id="bodycolor">
<body>
<div id="container">
<div id="menu">Menu:
<a class="menu" href="index.htm">Home</a> | <a class="menu"
`href="faculty.htm">Faculty</a> |
<a class="menu" href="courses.htm">
Courses</a> | <a class="gradecalculator" href="gradecalculator.htm">Grade
Calculator</a> | <a class="survey" href="survey.htm">Survey</a>
</div>
</div>
<div id="header">
<h1><center>CSE Center for Health Information Technology</center></h1>
<br>
<div id="links">
<center><a href="https://www.kennesaw.edu/"><img src="KSU Logo.jpg"
alt="Logo" style="width:100px;height:100px;" /></a></center>
<br>
<center><a href="http://ccse.kennesaw.edu/">College of Computing and
Software Engineering</a></center>
</div>
</div>
<h1>Please enter you information below</h1>
<form name="information" method="POST" action="action.php"
onsubmit="return
validate();">
<table width="500" border="0">
<tr>
<td width="150" bgcolor="#99CCFF"><strong>Name</strong></td>
<td><input type="text" name="name" size="20" maxlength="20" /></td>
</tr>
<tr>
<td bgcolor="#99CCFF"><strong>Email</strong></td>
<td><input type="text" name="email" size="20" maxlength="20" /></td>
</table>
<p> Major:
<input name="major" type="radio" value="Information Technology" />
Information Technology
<input name="major" type="radio" value="Software Engineering" />
Software Engineering
<input name="major" type="radio" value="Computer Science" />
Computer Science</p>
<p>
<input type="submit" value="Process" />
</p>
<p id="msg"></p>
</form>
</body>
</html>
Here is the PHP page:
action.php
<!DOCTYPE html>
<html>
<head>
<title>Survey Information Processing</title>
</head>
<body>
<h1>Form data</h1>
<p>Name: <?php echo $_POST["name"]?></p>
<p>Email: <?php echo $_POST["email"]?</p>
<p>Major: <?php echo $_POST["major"]?</p>
</body>
</html>
I'm totally new to PHP, so any help is greatly appreciated!
Your form method should be POST.
<form name="information" method="POST" action="action.php" onsubmit="return validate();">
And add a name to the submit button:
<input type="submit" value="Process" name="submit" />
Also, you could add this if condition:
<?php
echo "<pre>";
print_r($_POST); // Check if you're getting any POST data
echo "</pre>";
?>
<?php if (isset($_POST['name'])) { ?>
<h1>Form data</h1>
<p>Name: <?php echo $_POST["name"]; ?>
</p>
<p>Email: <?php echo $_POST["email"]; ?>
</p>
<p>Major: <?php echo $_POST["major"]; ?>
</p>
<?php } ?>
Hope this helps.
So the issue is your method is get but you're trying to access through post
Change
method="GET"
to
method="POST"
On your form.

Adwords Conversion Tracking in PHP Form

I have a html page with contact form. If someone fills the form, they see the "Thanks" message on the same page. HTML code for the page is
<form id="contact" method="post" action="demo">
<div class="row-fluid">
<div class="span6">
<input type="text" required placeholder="First Name" name="Firstname" />
</div>
<div class="span6">
<input type="text" required placeholder="Last Name" name="Lastname" />
</div>
</div>
<div class="row-fluid">
<div class="span6">
<input type="email" required placeholder=" * Email" name="Email" />
</div>
<div class="span6">
<input type="text" required placeholder="Country" name="Country" />
</div>
</div>
<div class="row-fluid">
<div class="span6">
<textarea name="comment" required placeholder="comment" size="100%"></textarea>
</div>
</div>
<div class="row4">
<input type="submit" data-loading-text="Loading..." class="btn button animated bounceIn" value="request information">
</div>
</form>
and the php code is
if ($Email=="") {
echo "<div class='alert alert-error'>
<a class='close' data-dismiss='alert'>×</a>
<strong>Warning!</strong> Please enter your email.
</div>
";
}
elseif ($firstName=="" or $lastName=="" or $country=="") {
echo "<div class='alert alert-error'>
<a class='close' data-dismiss='alert'>×</a>
<strong>Warning!</strong> Please fill all the fields.
</div>";
}
else{
mail($to, $subject, $msg, "From: $_REQUEST[Email]");
echo "<div class='alert alert-success'>
<a class='close' data-dismiss='alert'>×</a>
<strong>Thank you for your message!</strong>
</div>
";
}
Now I would like to integrate Google Adwords conversion code with the contact form. Could someone please assist me on this? Here is my conversion code:
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 955016975;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "_3SsCJzniVwQj86xxwM";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/955016975/?label=_3SsCJzniVwQj86xxwM&guid=ON&script=0"/>
</div>
</noscript>

Calling PHP function wth HTML button

I am developing website using php.I need to call php function using HTML Onclick event. How to do? Here I have given my code.
<?php
function insert() {
echo "in insert ";
$servername = "localhost";
$username = "shwetharao";
$password = "shwetha";
$dbname = "semilab";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$uname = $_POST['usernameu'];
$upass = $_POST['passwordu'];
echo $uname;
$sql = "INSERT INTO login (id, username, password)VALUES ('id','$uname','$upass')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>
<!DOCTYPE HTML>
<head>
<title></title>
</head>
<body>
<div id="main">
<div id="login">
<h2>Create User Account</h2>
<form action="" method="post">
<br><br><br>
<label>UserName :</label>
<br><br>
<input id="name" name="usernameu" placeholder="username" type="text">
<br><br><br>
<label>Password :</label>
<br><br>
<input id="password" name="passwordu" placeholder="**********" type="password">
<br><br><br>
<input name="button" type="button" value=" Create user " onclick="insert();">
</form>
</div>
</div>
</body>
</html>
I need to call function insert()[which is php function] on clicking button.How to achieve this?
Try this
<?php if(isset($_POST['submit'])){
insert();
}
?>
<!DOCTYPE HTML>
<head>
<title></title>
</head>
<body>
<div id="main">
<div id="login">
<h2>Create User Account</h2>
<form action="" method="post">
<br><br><br>
<label>UserName :</label>
<br><br>
<input id="name" name="usernameu" placeholder="username" type="text">
<br><br><br>
<label>Password :</label>
<br><br>
<input id="password" name="passwordu" placeholder="**********" type="password">
<br><br><br>
<input name="submit" type="submit" value=" Create user" >
</div>
</div>
</body>
</html>
you did two mistake first one is php tag at above, you wrote only "?" please change it to '<form action="" method="post">
inside of form you don't write action page name ..for example action = "myFile.php"
PHP: Is only run by the server and responds to requests like clicking on a link (GET) or submitting a form (POST).
HTML & Javascript: Is only run in someone's browser
I'm assuming your file looks something like:
<?php
function insert() {
echo 'I just ran a php function';
}
if(isset($_POST['submit'])){
insert();
}
?>
<!DOCTYPE HTML>
<head>
<title></title>
</head>
<body>
<div id="main">
<div id="login">
<h2>Create User Account</h2>
<form action="" method="post">
<br><br><br>
<label>UserName :</label>
<br><br>
<input id="name" name="usernameu" placeholder="username" type="text">
<br><br><br>
<label>Password :</label>
<br><br>
<input id="password" name="passwordu" placeholder="**********" type="password">
<br><br><br>
<input name="submit" type="submit" value=" Create user" >
</div>
</div>
</body>
</html>
Just change
<input name="button" type="button" value="Create user" onclick="insert();">
to
<input name="button" type="submit" value="Create user">
And paste your php code inside this
<?php if(isset($_POST['submit'])){
//paste you php code here
}
?>
<?php
if($_GET){
if(isset($_GET['insert'])){
insert();
}elseif(isset($_GET['select'])){
select();
}
}
function select()
{
echo "The select function is called.";
}
function insert()
{
echo "The insert function is called.";
}
?>
<input type="submit" class="button" name="insert" value="insert" />
<input type="submit" class="button" name="select" value="select" />
===============================================
<?php
if($_GET['button1']){fun1();}
if($_GET['button2']){fun2();}
function fun1()
{
//This function will update some column in database to 1
}
function fun2()
{
//This function will update some column in database to 2
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<button id="btnfun1" name="btnfun1" onClick='location.href="?button1=1"'>Update to 1</button>
<button id="btnfun2" name="btnfun2" onClick='location.href="?button2=1"'>Update to 2</button>
</body>
</html>
I did it using this code. Hope this helps.

Unable to show JQuery datepicker on my php page

I followed the source code on Jquery page to get a datepicker for my php page, but I cant get the calendar out. I think the Jquery is not loading for this page, can anyone tell me why? Thanks you
Here is my source code: I have my own designs for class element.
<html lang="en">
<head>
<meta charset="utf-8">
<title>Admin</title>
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/navi.css" media="screen" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$(function(){
$(".box .h_title").not(this).next("ul").hide("normal");
$(".box .h_title").not(this).next("#home").show("normal");
$(".box").children(".h_title").click( function() { $(this).next("ul").slideToggle(); });
});
</script>
<script src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<script>
function validateForm()
{
var x=document.forms["my_form"]["title"].value;
var y=document.forms["my_form"]["author"].value;
var z=document.forms["my_form"]["keywords"].value;
var type=document.forms["my_form"]["category"].value;
if (x=="" || y=="" || z =="" || type=="")
{
alert("Please fill in the required fields");
return false;
}
}
</script>
<body>
<div class="wrap">
<div id="header">
<div id="top">
<div class="left">
<p>Welcome, <strong><?php echo $_SESSION['login']?> </strong> [ logout ]</p>
</div>
</div>
<div id="nav">
<ul>
<li class="upp">Manage Content
<ul>
<li>› Admin Home</li>
<li>› Manage Posts</li>
<li>› Manage User</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<div id="sidebar">
<div class="box">
<div class="h_title">› Manage content</div>
<ul id="home">
<li class="b1"><a class="icon view_page" href="admin.php">Admin Home</a></li>
<li class="b2"><a class="icon report" href="viewPosts.php">Add Posts</a></li>
</ul>
</div>
<div class="box">
<div class="h_title">› Category</div>
<ul id="home">
<?php
include("includes/connect.php");
$sql = "SELECT post_type, COUNT(*) AS num FROM post WHERE post_status ='New' GROUP BY post_type";
$result = mysql_query($sql);
while($Cat_row= mysql_fetch_array($result)){
$type =$Cat_row['post_type'];
$number = $Cat_row['num'];
?>
<li class="b2"><a class="icon category" href="postType.php?cat=<?php echo $type?>"><?php echo $type." (".$number.")"?></a></li>
<?php }?>
</ul>
</div>
<div class="box">
<div class="h_title">› Archives</div>
<ul id="home">
<?php
include("includes/connect.php");
$sql_arc ="SELECT post_type, COUNT(*) AS numb FROM post WHERE post_status='Old' GROUP BY post_type";
$result_arc = mysql_query($sql_arc);
while($Arc_row= mysql_fetch_array($result_arc)){
$type_arc =$Arc_row['post_type'];
$number_arc = $Arc_row['numb'];
?>
<li class="b1"><a class="icon config" href="postArchive.php?type=<?php echo $type_arc?>"><?php echo $type_arc." (".$number_arc.")"?></a></li>
<?php }?>
</ul>
</div>
</div>
<div id="main">
<div class="full_w">
<div class="h_title">Add new Posts</div>
<form method="post" action="viewPosts.php" name="my_form" enctype="multipart/form-data" onsubmit="return validateForm()">
<div class="element">
<label >Title <span class="red">*</span></label>
<input type="text" name="title" class="text err" />
</div>
<div class="element">
<label>Author <span class="red">*</span></span></label>
<input type="text" name="author" class="text err" />
</div>
<div class="element">
<label>Keywords <span class="red">*</span></label>
<input type="text" name="keywords" class="text err" />
</div>
<div class="element">
<input type="text" id="datepicker">
</div>
<div class="element">
<label>Category <span class="red">*</span></label>
<select name="category" class="err">
<option value="">-- select category</option>
<option value="Class">Class</option>
<option value="Facilities">Facilities</option>
<option value="Services">Services</option>
<option value="Announcement">Announcement</option>
<option value="Promotions">Promotions</option>
<option value="News">News</option>
<option value="Uncategorized">Uncategorized</option>
</select>
</div>
<div class="element">
<label for="content">Page content <span>(required)</span></label>
<textarea id="editor1" name="content" class="textarea" rows="10"></textarea>
</div>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1',
{
// Load the German interface.
language: ''
});
</script>
<div class="entry">
<button type="submit" name="submit" class="add">Save Post</button>
<button class="cancel" type="reset" >Cancel</button>
</div>
</form>
</div>
</div>
<div class="clear"></div>
</div>
<div id="footer">
<div class="left">
<p>NUS Staff Club Admin Panel</p>
</div>
</div>
</div>
</body>
</html>
<?php
include("includes/connect.php");
if(isset($_POST['submit'])){
$post_title = $_POST['title'];
$post_date = date("Y-m-d");
$post_author = $_POST['author'];
$post_keywords = $_POST['keywords'];
$post_type = $_POST['category'];
$post_content = $_POST['content'];
$post_status = 'New';
// $post_image = $_FILES['image']['name'];
// $image_temp = $_FILES['image']['tmp_name'];
/*if(empty($post_title) || empty($post_author) || empty($post_keywords) || empty($post_type) || empty($post_content) ){
exit();
}*/
// else{
// move_uploaded_file($image_temp,"../image/$post_image");
$insert_query = "insert into post (post_title,post_date,post_author,post_keywords,post_type,post_content,post_status) values ('$post_title','$post_date','$post_author'
,'$post_keywords','$post_type','$post_content','$post_status')";
if(mysql_query($insert_query)){
echo "<script>alert('Post has been pushlished successfully')</script>";
echo "<script>window.open('admin.php','_self')</script>";
}
else{ echo "<script>alert('failed')</script>";}
// }
}
?>
<?php }?>
You're calling your element before it's created...
replace
$(function() {
$( "#datepicker" ).datepicker();
});
by
$().ready(function() {
$( "#datepicker" ).datepicker();
})
;

Categories

Resources