Jump to content

form success filure


kayz100

Recommended Posts

I can't seem to see the problem with my success and not success form below. The form is sent successfully but keep outputting oops try again

 

<?php
  if ($success) {
  $message = "Message sent succesfully! Thank you.";
  } else {
  $message = "Oops! Try again!";
  }
  echo '<div id="message">'.$message.'<div id="close-button"></div></div>';
?>
Link to comment
Share on other sites

You have no condition in the IF statement.

 

$success needs to have a value, so for your example when the form is submitted by the user sucessfully set $success to be 'YES'.

 

And then include that in the IF statement.

<?php

  if ($success=='YES') {
  $message = "Message sent succesfully! Thank you.";
  } else {
  $message = "Oops! Try again!";
  }
  echo '<div id="message">'.$message.'<div id="close-button"></div></div>';
?>



Link to comment
Share on other sites

Actually, what am I saying... you can have an IF statement without a conditon.

 

As long as $success is true, then that will work.

 

So... you need to make sure you set $success after the form has been sent...

$success = true;

debug by printing the contents of $success at the end of your current code and see what is actuall in there

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.