Jump to content

display a success message after form is submitted


$php_mysql$

Recommended Posts

how can i disply this message withing the form echo "data submitted successfully!";

 

currently after validation check when data is entered the message show on top of my page not within the form

 


function insertDATA($postData) {		

if(!ifEmailExists($postData['email'])){
$sql = " INSERT INTO tbl SET
		email = '".$postData['email']."',
		name	= '".$postData['name']."',
		phone	= '".$postData['phone']."'
		";
                      echo "data submitted successfully!";//this line withing the form
		executeSql($sql);
}		

Link to comment
Share on other sites

function insertDATA($postData) {		

if(!ifEmailExists($postData['email'])){
$sql = " INSERT INTO tbl SET
		email = '".$postData['email']."',
		name	= '".$postData['name']."',
		phone	= '".$postData['phone']."'
		";
                      echo "data submitted successfully!";//this line withing the form
		$res = executeSql($sql);
if($res) {
echo "<img src='path/to/image.jpg'></img.";
} else {
die(mysql_error());
}

}		

 

I don't know if that will work, since you never told us how executeSql works, and you'll have to have the link for the image in the img tag.

 

Link to comment
Share on other sites

how can i put html inside a variable?

//make sure there are NO space in your html or you wil lget a unexpected T_SL error
$example= <<<EOF <html><body></body></html> EOF;
echo $example;

 

 

you will need to do IF or ELSE statements to determine what gets outputted where.

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Not 100% sure if I am understanding what exactly you want but if I am this would work......

 

function insertDATA($postData) {		

if(!ifEmailExists($postData['email'])){
$sql = " INSERT INTO tbl SET
		email = '".$postData['email']."',
		name	= '".$postData['name']."',
		phone	= '".$postData['phone']."'
		";

                      return header(sprintf("Location: %s", 'yourpage.php?success=yes'));
                      //echo "data submitted successfully!";//this line withing the form
		executeSql($sql);
}

 

When the query is sucessful the use will be redirected back to the original page with the message.

 


// yourpage.php


    if(!empty($_GET['success'])){

      if($_GET['success'] == 'yes'){

     $Success = 'data submitted successfully';

}

}

//Then place this where ever you want the message to appear.

if(isset($Success)){

echo $Success;

}

 

 

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.