Jump to content

Whats wrong with my form when I rename my files?


stefsoko

Recommended Posts

I currently have a small 2 page message board, the main file is named index.php and the other core.php - I would like to rename the main file with the form to chat.php, but when I do that, the script no longer posts messages, and goes to the website root. Can someone tell me whats wrong?

 

Here is the form info from the current index.php (that i wish to rename chat.php)

 

<form action="./" method="post">
<p>name (25 chars max)<br>
<input id="name" name="author" maxlength="20" size="25"></p>
<p>message (150 chars max)<br>
<input id="message" name="message" maxlength="150" size="45"></p>
<p>what is <?php echo "$num1 &#43; $num2?" ?><br>
<input id="captcha" name="captcha" maxlength="2" size="10"></p>
<p><input id="submit" name="submit" type="submit" value="submit"> (ip addresses are recorded)</p>
</form>

 

and the 2nd file core.php's function that I think is acting up (here or with the form above?)

 

	function getPosts() {
$author = isset($_POST['author']) ? $_POST['author'] : false;
$message = isset($_POST['message']) ? $_POST['message'] : false;
	global $nameMax;
	global $messageMax;
	global $error;

		if ($author && $message && ($error==false) ) {
		if (strlen($author) <= $nameMax && strlen($message) <= $messageMax) {
			$this->inputPost($author, $message);
			header('Location: ./'); }

 

Why when I rename index.php to chat.php is it not working and falling back to the website root when I submit? any help would be great! :confused: I am sure it is something simple, but I am new...

Link to comment
Share on other sites

The action element needs to be changed to reflect the new filename. So you would want to set it to chat.php...

 

A more general solution, since this page is submitting to itself, would be to just use action="", causing it to submit to itself, arguements and all (were there any set).

Link to comment
Share on other sites

The action element needs to be changed to reflect the new filename. So you would want to set it to chat.php...

 

A more general solution, since this page is submitting to itself, would be to just use action="", causing it to submit to itself, arguements and all (were there any set).

 

so i change the chat.php form action to this...

<form action="" method="post">

or

<form action="chat.php" method="post">

 

but what about this line in the core.php file...?

 

header('Location: ./')

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.