How to put this code in my registration code in my program that if the registration is successful this will pop-up?? I'm new with jquery so i dont know how to do this stuff...help me guys please.
<script>
$(document).ready(function() {
// show a dialog box when clicking on a link
$("#success").on('click', function(e) {
e.preventDefault();
$.Zebra_Dialog('<strong>Congratulations </strong>' +
'You are now successfully registered!');
});
});
</script>
here is my php code:
<?php
if(isset($_POST['save'])) {
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$position = $_POST['position'];
$username = $_POST['username'];
$password = $_POST['password'];
$dateregistered = date("Y-m-d H:i:s");
if (!$_POST['fname'] || !$_POST['lname'] || !$_POST['position'] || !$_POST['username'] || !$_POST['password'] ) {
echo "You did not complete all of the required fields!";
} else {
$query="INSERT INTO users (position, fname, lname, username,password,dateregistered) VALUES ('$position','$fname','$lname','$username','$password',CURRENT_TIMESTAMP) ";
mysql_query($query);
if($query)
echo "You Successfully Created an Account!";
}
}
?>
i want to replace the echo thing into jquery code...anyone know how???
Andrei Zhamoida
1,4632 gold badges21 silver badges32 bronze badges
asked Jan 16, 2014 at 8:34
eloginko
971 gold badge2 silver badges9 bronze badges
4 Answers 4
append jquery function is your php code
<?php
if(isset($_POST['save']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$position = $_POST['position'];
$username = $_POST['username'];
$password = $_POST['password'];
$dateregistered = date("Y-m-d H:i:s");
if (!$_POST['fname'] || !$_POST['lname'] || !$_POST['position'] || !$_POST['username'] || !$_POST['password'] )
{
echo "You did not complete all of the required fields!";
}
else
{
$query="INSERT INTO users (position, fname, lname, username,password,dateregistered) VALUES ('$position','$fname','$lname','$username','$password',CURRENT_TIMESTAMP) ";
mysql_query($query);
if($query){
echo "You Successfully Created an Account!";
// append here your jquery code
?>
<script>
$(document).ready(function() {
// show a dialog box when clicking on a link
$.Zebra_Dialog('<strong>Congratulations </strong>' +
'You are now successfully registered!');
});
</script>
<?php
}
}
}
//corrected indentation
?>
answered Jan 16, 2014 at 8:39
Satish Sharma
9,6356 gold badges32 silver badges52 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
pythonian29033
no problem man, just check it next time, I was going to give this answer but you were first
**Try this code.......**
<?php
if(isset($_POST['save']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$position = $_POST['position'];
$username = $_POST['username'];
$password = $_POST['password'];
$dateregistered = date("Y-m-d H:i:s");
if (!$_POST['fname'] || !$_POST['lname'] || !$_POST['position'] || !$_POST['username'] || !$_POST['password'] )
{
echo "<script>
$(document).ready(function() {
$('#success').on('click', function(e) {
e.preventDefault();
$.Zebra_Dialog('<strong>Congratulations </strong>' +
'You did not complete all of the required fields!');
});
});
</script>";
}
else
{
$query="INSERT INTO users (position, fname, lname, username,password,dateregistered) VALUES ('$position','$fname','$lname','$username','$password',CURRENT_TIMESTAMP) ";
if(mysql_query($query)){
echo "<script>
$(document).ready(function() {
$('#success').on('click', function(e) {
e.preventDefault();
$.Zebra_Dialog('<strong>Congratulations </strong>' +
'You Successfully Created an Account!');
});
});
</script>";
}
}
}
?>
answered Jan 16, 2014 at 8:46
Indrajeet Singh
2,99927 silver badges28 bronze badges
Comments
You can simply use
echo "<script>alert('You Successfully Created an Account!')</script>";
Aniket Kulkarni
13k10 gold badges70 silver badges94 bronze badges
Comments
Try to do like this:
if($query)
{
?>
<script>
$(document).ready(function() {
$.Zebra_Dialog('<strong>Congratulations </strong>' +
'You are now successfully registered!');
});
</script>
<?php
}
answered Jan 16, 2014 at 8:42
Felix
38.2k8 gold badges46 silver badges56 bronze badges
Comments
default
$_SESSION