Wednesday 8 May 2019

html - Unable to use echo with php form



My PHP form seems to be operating fine. The page comes up and when I click on the submit button, the isset($_POST['submitted']) condition at the start is hit and the code run.



The only issue is that I have a couple of echo lines in the code to produce a JS alert box. Neither seem to be getting called. I'm not sure that the external PHP functions are being called either as I have no way of testing the value returned.




My PHP looks like this



$output = checkData(); 
if ($output != "done")
{
echo '';
}
else

{
createMeeting();
echo '';
header('Location: index.php');
}
} else { ?>


...



}
?>


My checkData() function simply checks to see if the other parts of the form data are empty and exit with either "done" (no errors) or a message if one of the form elements is empty.



createMeeting() will create a meeting based on the data and submit it to my server - currently, it takes the same data as checkData() and then returns.




Both functions come back with no errors when I run it through an online PHP code checker.


Answer



I've tried your code and it seems to work fine in my case.



$output = "done"; //even if this line is not equal to 'done', the code still works fine
if ($output != "done")
{
echo '';
}

else
{
// createMeeting();
echo '';
// header('Location: index.php');
}
} else { ?>


...



}
?>


So to my knowledge, there're errors with your createMeeting() or checkData() functions. Can you please be more specific with the error messages (if any)?


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...