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
https://forums.phpfreaks.com/topic/284644-form-success-filure/
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
https://forums.phpfreaks.com/topic/284644-form-success-filure/#findComment-1461750
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
https://forums.phpfreaks.com/topic/284644-form-success-filure/#findComment-1461800
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.