Jump to content

[SOLVED] Popup Message after form submitted


karl_009

Recommended Posts

Hello,

 

I have this code and it displays messages after the form is submitted, how I would go about redirecting this to another page and a popup message saying successful.

 

I believe it will be the IF statement at the end that I will need to update?

 

Here is the code that I am using now;

 

<?php
require ($_SERVER['DOCUMENT_ROOT']."cmstesting/config/db_config.php");
$connection = mysql_connect ($db_host, $db_user, $db_pass) or die ("Error with Connection");
mysql_select_db ($db_name, $connection);

	$conid = $_POST["conid"];
	$submitted = $_POST["submitted"];

$query = "UPDATE contacts SET title='{$_POST["title"]}', first='{$_POST["first"]}', last='{$_POST["last"]}', suffix='{$_POST["suffix"]}', company='{$_POST["company"]}', address1='{$_POST["address1"]}', address2='{$_POST["address2"]}', city='{$_POST["city"]}', town='{$_POST["town"]}', country='{$_POST["country"]}', postcode='{$_POST["postcode"]}', website='{$_POST["website"]}', email='{$_POST["email"]}', hp1='{$_POST["hp1"]}', hp2='{$_POST["hp2"]}', hp3='{$_POST["hp3"]}', mp1='{$_POST["mp1"]}', mp2='{$_POST["mp2"]}', mp3='{$_POST["mp3"]}', notes='{$_POST["notes"]}' WHERE conid='$conid'";

	$result = mysql_query($query);

if ($result)
{
echo "Successful";
echo "<BR>";
echo "<a href='contact_view.php'>View</a>";
}
else
{
echo "ERROR";
}

?>

 

Thanks

Karl

Link to comment
Share on other sites

Thanks for that, the page now redirects to the page...

 

Is there away to have a popup message popup, then continue on to the page...

 

<?php
if ($result)
{
//	echo "Successful";
//	echo "<BR>";
//	echo "<a href='contact_view.php'>View</a>";

echo "<script type='text/javascript'>alert('Successful')</script>";
header("Location: http://localhost/cmstesting/contact_view.php");
}
else
{
echo "ERROR";
}

?>

 

 

I have included;

echo "<script type='text/javascript'>alert('Successful')</script>";

 

Is there away to execute this code then the header code after this has been OK...

 

Many Thanks

Karl

 

Link to comment
Share on other sites

Thanks for that, the page now redirects to the page...

 

Is there away to have a popup message popup, then continue on to the page...

 

<?php
if ($result)
{
//	echo "Successful";
//	echo "<BR>";
//	echo "<a href='contact_view.php'>View</a>";

echo "<script type='text/javascript'>alert('Successful')</script>";
header("Location: http://localhost/cmstesting/contact_view.php");
}
else
{
echo "ERROR";
}

?>

 

 

I have included;

echo "<script type='text/javascript'>alert('Successful')</script>";

 

Is there away to execute this code then the header code after this has been OK...

 

Many Thanks

Karl

 

 

No, what you should do is load that script on the new page on the top...this way right

before the new page loads, you load the pop up...

 

 

Link to comment
Share on other sites

I found a solution, it did not use PHP but I thought I would post it anyway.

 

<?php
if ($result)
{
// Successful popup message, redirected back to view contacts
echo "<script type='text/javascript'>alert('Successful - Record Updated!'); window.location.href = 'contact_view.php';</script>";
}
else
{
// Unsuccessful popup message, redirected back to view contacts
echo "<script type='text/javascript'>alert('Unsuccessful - ERROR!'); window.location.href = 'contact_view.php';</script>";
}
?>

 

Thanks for the replies

Karl

Link to comment
Share on other sites

I found a solution, it did not use PHP but I thought I would post it anyway.

 

<?php
if ($result)
{
// Successful popup message, redirected back to view contacts
echo "<script type='text/javascript'>alert('Successful - Record Updated!'); window.location.href = 'contact_view.php';</script>";
}
else
{
// Unsuccessful popup message, redirected back to view contacts
echo "<script type='text/javascript'>alert('Unsuccessful - ERROR!'); window.location.href = 'contact_view.php';</script>";
}
?>

 

Thanks for the replies

Karl

 

Good script, I will save that script myself for future purposes...

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.