PHP form question-link a button to url

Hello Experts,
     I am a PHP beginner and I am trying to create a simple form in php page.
I made a form with html and when I click a submission button, it goes to a php page.
In that page, I would like to create buttons, one is if a user input info from html page is correct, click "Yes" and then goes to another page, stating thank you.  Another button is "No", which means input info is not right and go back to the first html form.

     Up to display the user input info, I'm doing fine.  But somehow, once I add the last part of the code, it stops working and get a blank page.
     The code I have an issue is as follows:

     
print "<p>If this is correct, click <input type="button" onclick="location.href('url')" value="Yes" />. 
Otherwise, click <input type="button" onclick="location.href('url')" value="No" /></p>";

Open in new window


     If I comment out the above code, the PHP page works fine.  But I would like to add an additional function on my form.  
     I might be doing totally wrong, as I don't have coding brains, but I really appreciate if someone let me know what part I am not doing right and how to solve my problem.

     Thank you in advance.
sabregirlAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marco GasiFreelancerCommented:
You have to escape double quotes

print "<p>If this is correct, click <input type=\"button\" onclick=\"location.href('url')\" value=\"Yes\" />.
Otherwise, click <input type=\"button\" onclick=\"location.href('url')\" value=\"No\" /></p>";
0
Marco GasiFreelancerCommented:
If you don't escape double quotes, php engine will think that your string ends at the next double quotes, that is at the <input type= All the rest of your code will be treated as an error. Since probably you have no set properly error displaying, you get a blank page. At the top of your script it's convenient to put these two lines (but only in development environment: don't forget to delete them in your production web site in order to avoid to give useful informations about your code to bad guys):

error_reporting(E_ALL);
ini_set('display_errors', 'On');

Open in new window



You might also consider to use heredoc notation:

echo <<<FRM
<p>If this is correct, click <input type="button" onclick="location.href('url')" value="Yes" />. 
Otherwise, click <input type="button" onclick="location.href('url')" value="No" /></p>;
FRM;

Open in new window


This way you'll avoid to worry about escaping quotes when you'll print forms and other strings. Please, be careful with the big pink warnin in the Php man page to avoid errors.

Cheers
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sabregirlAuthor Commented:
Thank you so much for your quick responses, marqusG!
I set error_reporting(E_ALL & ~E_NOTICE); on my codes, but I guess it's  not enough...
I knew that I need to escape double quotes, but I didn't think about that also applies to even in my input type...  I need to pay more attention when I write some codes...
Thank you again for your help.  I really appreciate it :)
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Marco GasiFreelancerCommented:
Glas to help you: when we're writing code the attention is never enough - it looks like a James Bond movie title ;)

Thanks for points and good luck with your project.
Marco
0
Marco GasiFreelancerCommented:
Have you seen? I wrote 'Glas' instead of 'Glad': the attention is never enough indeed!!!
0
sabregirlAuthor Commented:
You are so nice to a beginner, Marco :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.