Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
So I have a html form and I have an URL where it will be submitted, say the URL is www.myformsubmit.com/form_submit.php. This form_submit.php will give me a text saying if everything is correct in the form or prints out an error message.
What I want to do is that to do is that after the form is submitted to form_submit.php I want to redirect users to a thank you page. My question, is there a way to do this without having to touch the form_submit.php, if yes how?
With your current setup, you can't redirect to another page without modifying form_submit.php.
You can have the form submit to itself, and then do something like this:
<?php
// Optionally, also make sure that there are no errors.
if (isset($_POST["SomeInputValue"])):
{
// Must be BEFORE any output is sent!
header("Location: /thank_you.php");
}
else
{
// Display the form page.
}
?>
My question, is there a way to do this without having to touch the form_submit.php, if yes how?
You want to check if everything is fine from form_submit.php but you do not want to post data to it? I think this is really not possible.
is there a way to do this without having to touch the form_submit.php,
if yes how?
The short answer would be no. To correctly answer your question we need to know why you cannot modify form_submit.php. This is because a simple line of code could be added to redirect to a "thank you" page when the form is correctly filled in.
(Will edit this accordingly as the question is developped)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
this is the php code im using and want these errors(Echos) to be displayed in the html form without refreshing it after the submit button is clicked
.
THANK YOU
<?php
include 'index.php';
........
if (mysqli_num_rows($num_u) > 0 && mysqli_num_rows($num_e) > 0 ) {
echo "User Already Excist";
}
<html>
Unfortunately, changing page content without refreshing a page isn't possible in PHP. PHP runs when the page loads but once it's finished processing the only way to start the same or a new script is to make a new request. You'll have to use Javascript to execute an ajax request to populate the error.
You need to use JQuery's ajax methods.
They can get data from the server and update your dom on the fly without a page reload.
This is pretty straightforward using Get or Post
JQuery also has some other ajax methods which may be useful as well.
You can check this Create Login Form Using jQuery blog for more details, I hope it's help to you
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
when submitting a form in php i am using: "header('Location: contact.php');" to redirect back to the current page after hitting submit. However the form is at the bottom of the page and each time submit is hit it is redirected back to the top of the page. is there anyway to redirect back to the bottom of the page?
Yes, You can take a id to part of a page you want to return to and then return to it, see following code:
for example you want to return to bellow div:
<div id="bottom"></div>
your php code to redirect to this:
header('Location: contact.php#bottom');
You could check if your page was the pre ious page with window.history and if so, scroll down with window.scroll to.
I really recommend to not to that and use AJAX
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm a beginner in PHP. my login page is a login.html page and it posts inputted data to a logged.php page. and in this page it checks inputted data with my DB and if it was true, it showed this logedd.php page or if not, it returns to login.html page with the code below:
header('Location:Login.html');
and also when I press Logout icon in logged.php, it returns to login.html by a href link in it. like this:
press to logout
Now my question is, Is this login and logout way secure or not? if not please describe why and how to make it secure? thanks.
It does not work this way. You look up your credentials in database if they match with your form input you make a session. If session exist you have additional content. This is a very simple description of how it works.
Oh and about security. look up these function. password_hash($_POST["password"], PASSWORD_DEFAUT); for inserting password. When you want to compare password from database with form input you use password_verify($inputpassword, $databasepassword). Also use htmlentities and bind parameters.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am creating a forum software for my first time I know most of PHP just not a few things.
Anyway,
Say when someone hits enter like on this
"Like this i just hit enter"
It will display as a new line when the topic is posted how can I archive this?
Right now even if I went to a new line the post will still display like this "sssssssssssssssss" the user needs to add to break it but I need to disable HTML for security reasons.
I now I could get PHP to add automatically when the post is submitted but then will be displayed to the users and I be disabling html.
Thanks!
You need to use the nl2br() in the PHP. It automatically converts the linebreaks to <br> tags.
Say if the user typed data on the <textarea> of your form and when he clicks Submit , it reaches to your PHP page say submit.php , in that page you should be doing like this..
submit.php
<?php
$textareadata = isset($_POST['textareadata'])? nl2br(htmlspecialchars(($_POST['textareadata']))) : "Not Sent";
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
My workaround getting the "Resubmit post data" dialog when users refresh, and respectively sending stuff twice, was to force a refresh on the page via javascript when content is posted. Which seemed to work in webkit browsers and IE but unfortunately firefox doesn't work that way.
The problem is that after the post I need the user to be returned to the same page which kinda confused me on using the post/redirect/get method since it is described there that another page needs to be supplied. Even if I send a redirect header from php itself firefox still asks about resubmitting. Can anyone suggest how I can solve this problem? Thank you in advance!
EDIT: Here's some code
if($_SERVER['REQUEST_METHOD']=="POST"){
$user->validateSettingsData($_POST, TRUE);
echo "<div class='win box10'>Changes saved, please wait..</div>";
header("Refresh: 2; url=");
exit();
}
You can use PHP to redirect. For example:
if (isset($_POST)) {
// processing the data
// ....
header('LOCATION: ' . $_SERVER['REQUEST_URI']); // <-- for dynamic URL
exit();
}