Using div to redirect to php script

i have this div that i am using as a sort of button, most of the time, i just use it to redirect to another page, but this time, i want it to run some php before it redirects to the next page.

<div class="build_detail_option_ele_wrap" onclick="location.href="builders_checkout.php";"></div>

Could i just make it redirect to builders_checkout.php, which creates some sessions etc... and then from there redirect to the end page.

(I know i could do this easier through using a submit button instead, but circumstances mean i can't use one here. )

Is this a good idea, or are there negatives to doing this?



Since no one has actually given the (obvious) solution:

<a class="build_detail_option_ele_wrap" href="builders_checkout.php"></a>

Add this to your CSS, and it won't be visibly different:

a.build_detail_option_ele_wrap {
    text-decoration: none;
    color: inherit;
    display: block;

There's nothing "wrong" with it, but you'd have better results if you used an <a href="..."> tag (optionally, set style="display:block" to make it behave like a <div>).

If you are insistant on a <div>, use single quotes around the builders_checkout.php string.

Pass a querystring on your url containing the page you should redirect after that script. I used next.

 ... builders_checkout.php?next=lol_page.php ...

In your builders_checkout.php, use something like this in the end of your script:

// if next is set, we will redirect it to next value (lol_page.php);
     header('Location: ' . $_GET['next']);

If you any question or problem to understand that, just ask.

Need Your Help

Links to AJAX URLs

jquery ajax url

I've got a page on my site that requests quite a bit of content via AJAX. The problem I've run into is that if you've been poking around on the site and are on a page that doesn't technically have ...

Android NDK future extended support for C++

android irc android-ndk

Is there any info about the future of extending the safe C++ header list in the NDK (or maybe some hints to what might be safe to use) ? Or how soon we can expect the next NDK update? Also will the...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.