PHP (noob)

Soldato
Joined
8 Oct 2005
Posts
4,184
Location
Midlands, UK
Hi,

If i get:

Method Not Allowed

The requested method POST is not allowed for the URL /site/join.html.

when i try to run a simple php script does it mean POST has been disabled by my host (tsohost)?

Just made a very very basic script for my site that posts the info from a form onto a page, using the following:

PHP:
<? php 

define("BR", "<br />");

$name = $_POST["txtname"];
$password = $_POST["txtpassword"];
$email = $_POST["txtemail"];
$location = $_POST["optlocation"];
$age = $_POST["txtage"];
$gametypes = $_POST["optgametypes"];
$currentclan = $_POST["txtcurrentclan"];
$previousclans = $_POST["txtpreviousclans"];
$additionalinfo = $_POST["txtadditionalinfo"];

echo "Name: $name" . BR . "Password: $password" . BR . "Mail: $email" . BR . "Location: $location" . BR . "Age: $age" . BR . "Gametypes: $gametypes" . BR . "Current Clan: $currentclan" . BR . "Previous Clan: $previousclans" . BR . "Other Info: $additionalinfo";

?>

Thanks
 
Last edited:
Have you embedded your php code in your html page correctly? Also, check that your server allows for php code in html pages.
 
bah, just renamed the html file to .php. I assume to script runs now as i get the following error now:

Code:
[b]Parse error[/b]:  syntax error, unexpected T_STRING in [b]/home/rallport/public_html/site/submit.php[/b] on line [b]3[/b]
 
bah, just renamed the html file to .php. I assume to script runs now as i get the following error now:

PHP:
Parse error:  syntax error, unexpected T_STRING in /home/rallport/public_html/site/submit.php on line 3

Any ideas?
 
Right, thats works now and outputs the data on an unformatted page. On the original page where the form is located, everything is formatted nicely, links to css files etc. My question: how can i include the php code on this page so rtaht formatting is included - e.g. outputs on the same page. I'm kinda stuick as the form action is "submit.php".

Thanks for any help.

EDIT: just figured that out, apologies for the noob question.
 
Last edited:
Again, apologies for my noob questions, as everyone on here seems to be very knowledgeable on programming. I have declared a variable called today

PHP:
$today = date("F j, Y, g:i a");

Now, how can i show the date in 48 hours from $today ?
 
suarve said:
Again, apologies for my noob questions, as everyone on here seems to be very knowledgeable on programming. I have declared a variable called today

PHP:
$today = date("F j, Y, g:i a");

Now, how can i show the date in 48 hours from $today ?
PHP:
$DayAfterTomorrow = mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"));
 
suarve said:
The above outputs: "1165363200". I'm sure i have messed up somewhere though.....
Fails at what it's meant to do, but it's a good random string generator :D

You need to date that up first. The above is the number of seconds since 1st Jan 1970 (http://uk.php.net/manual/en/function.mktime.php)

Code:
date("m-d-Y", mktime(0, 0, 0, date("m")  , date("d")+2, date("Y")));
 
Last edited:
Just to add... if you are going to allow people to input data into your website and you are going to display that data then you need to use both mysql_real_escape_string() and strip_tags() to stop people putting HTML, Javascript and the like into your form.

Have a look at Rob's excellent article (Which I found very useful :) ) here.
 
Back
Top Bottom