Jump to content

My Code Isn't Working?


happyhippy

Recommended Posts

Code goes no place but changes some figures on the tool bar.  :wtf:

 

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
function OnSubmitForm()
{
$choose = "";
$variable1 = "";
$variable2 = "";

$choose = $_GET["pages"];
$variable1 = $_GET["page1"];
$variable2 = $_GET["page2"];

if ($choose == $variable1)
{
header("Location: http://url.com/page1");
}
if ($choose == $variable2)
{
header("Location: http://url.com/page2");
}
}
?>

<form name="pages" onsubmit="return OnSubmitForm()">
<input type="text" name="call" size="25">
e<select name="pages">
<option name="page1" value="non1">page1</option>
<option name="page2" value="non2">page2</option>
</select>
<input type="submit" name="submit" value="submit">
</p>
</form>

Link to comment
Share on other sites

So far I know, form onSubmit is a scripting event that occurs when the user attempts to submit the form to the CGI. Form onSubmit can be used to do some error checking on the form data, and to cancel the submit if an error is found.

 

Have you tried keeping form action blank like this: <form action="" or $_SERVER['PHP_SELF'] ?

Link to comment
Share on other sites

You can't call a PHP function with anything but PHP. You have to remember that PHP is executed by the server when the page is requested. by the time the HTML is output and stuff (whatever the user sees) is all clientside. If you want you could use AJAX, but it would probably be easier to just use javascript. Or you could just make it a 2 step process, and have the form submit to a page that would execute that PHP, and that page redirects based on whatever criteria you have.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.