0

I have one a page webiste www.yahavi.com (all pages in 1 html) in which different pages are referenced using their div id (eg; #home, #contact ). After successful sign up I want to direct user to my thankyou page with id #thanku . How can i do that using my PHP script that runs after form submission.

home url: www.yahavi.com/#home
form at : www.yahavi.com/#contact
thankyou: www.yahavi.com/#thanku

I am using header (Location: /#thanku) in my PHP but this doesnt work.

Note: I dont want a complete new html page to reload.

Deepak S Rautela
  • 67
  • 1
  • 1
  • 13

2 Answers2

0

You can do it with just PHP. No need for JavaScript or jQuery.

Declare a global variable for storing your base path like this

$BASE_URL="www.yahavi.com/";

and redirect to the specified page like

header("Location:'".$BASE_URL."#thanku'");
Lal
  • 14,726
  • 4
  • 45
  • 70
  • How is that any different than what is being done now? Either redirecting to "`/#thanku`" or "`http://yahavi.com/#thanku`" should be the same, shouldn't it? Also you're missing the protocol, so it wouldn't work as expected anyway. – Mike Apr 07 '15 at 18:37
0

You can use javascript on your PHP code like this:

<?php

<script> location.href="#thanku" </script>

?>

Try that. I hope this helps.

UPDATE

If you do AJAX instead, it would be best. After signup, if the user signups successfully, on the javascript file you can use location.href="#thanku".

For that, you would need to do an AJAX request in your signup form.

Erick
  • 823
  • 16
  • 37
  • This is an error..You certainly cant do it like `location.href="#thanku" ?>`.. Instead it can be done like `location.href='#thanku'"; ?>` – Lal Apr 08 '15 at 09:11