Jump to content
Sign in to follow this  
antifan

PHP kontakt form

Recommended Posts

Pozdrav. Pokusao sam da uradim PHP kontakt formu za slanje maila pomocu tutorijala. Sve sam uradio kako treba, i ubacio sam na stranu gde treba, ali kada kliknem dugme za slanje , pojavljuje mi se ova poruka:

 

server error:405 - HTTP verb used to access this page is not allowed

 

Citajuci malo shvatio sam da je problem sa serverom i izvesnim IIS-om...

 

Ne znam mnogo o PHP-u, poznajem HTML i CSS, pa ako neko zna u cemu bi mogao da bude problem i kako dagaresim, neka pise. Bio bihveoma zahvalan :)

 

 

 

Hvala

Share this post


Link to post
Share on other sites

Uh, nemoj IIS da koristis na windows-u, lakse ti je da uzmes xampp:

 

https://www.apachefriends.org/index.html

 

 

ili sta god da je popularno ovih dana :)

 

Jednim install-om dobices php, apache i mysql bazu, a to je sve sto ti je potrebno da pocnes da radis.

 

 

 

 

A error koji dobijas je verovatno zato sto saljes POST metod a server ocekuje GET, ili tako nesto, 405 greska znaci to.

Share this post


Link to post
Share on other sites

ah, ja sam mislio da je greska kod tebe na masini.

 

Jeste da sam admin, ali me nije nimalo blam da kazem da APSOLUTNO pojma nemam o IIS :D

 

 

To je jednostavno, ne bas najsrecnija kombinacija, svi normalni koriste Apache ili NginX. Vidi sa podrskom tog hosting-a, mozda su zabranili POST... ne znam, nagadjam...

Share this post


Link to post
Share on other sites

Ma ja da imam pojma ne bih ovde postavljao glupa pitanja :)

Ja sam graficki dizajner koji je naucio nesto malo html-a i uradio sajt za prijatelja,ali je ostala ta kontakt forma koja mi zadaje muke.

 

Ok, kako da formulisem svoje pitanje ako budem trazio pomoc provajdera? :) (u pitanju je orion)

 

Hvala

Share this post


Link to post
Share on other sites

Nemam ekstenzije.

 

Ovo je kod ako nesto znaci.Mozda postoji neka greska?....

 

 

 

 

<?php

 

if (isset($_POST['contact_name']) && isset($_POST['contact_email']) && isset($_POST['contact_text'])) {

$contact_name = $_POST['contact_name'];

$contact_email = $_POST['contact_email'];

$contact_text = $_POST['contact_text'];

 

if (!empty($contact_name) && !empty($contact_email) && !empty($contact_text)) {

 

$to = 'milosweb@gmail.com';

$subject = 'Contact form submitted.';

$body = $contact_name."\n".$contact_text;

$headers = 'From: '.$contact_email;

 

if(@mail($to, $subject, $body, $headers)) {

echo 'Thanks for contacting us.';

 

} else {

echo 'Sorry, an error occured. Please try again later.';

 

}

 

 

 

} else {

echo 'All fields are required.';

}

 

 

 

 

 

 

 

}

 

 

 

?>

 

 

 

<form action="index.php" method="POST">

Name:<br><input type="text" name="contact_name" maxlenght="25"><br><br>

Email address:<br><input type="text" name="contact_email" maxlenght="50"><br><br>

Message:<br>

<textarea name="contact_text" rows="6" cols="30" maxlenght="1000"></textarea><br><br>

<input type="submit" value="Send">

 

</form>

 

Share this post


Link to post
Share on other sites

Druze problem je sto server blokira POST request.

A sad pitanje - na kom serveru to radis - jel free ili paid? Ima free servera kojima radi sve normalno, mozes ih lako google, paid su nikad jeftiniji, a ako hoces da vezbas skini XAMPP, WAMP, MAMP sta god hoces od toga i uzivaj.

Share this post


Link to post
Share on other sites

<?php
if (isset($_POST['contact_name']) && isset($_POST['contact_email']) && isset($_POST['contact_text']))
{
        $contact_name = $_POST['contact_name'];
        $contact_email = $_POST['contact_email'];
        $contact_text = $_POST['contact_text'];

        if (!empty($contact_name) && !empty($contact_email) && !empty($contact_text))
        {
                $to = 'milosweb@gmail.com';
                $subject = 'Contact form submitted.';
                $body = $contact_name."\n".$contact_text;
                $headers = 'From: '.$contact_email;

                if(@mail($to, $subject, $body, $headers))
                {
                        echo 'Thanks for contacting us.';
                }
                else
                {
                        echo 'Sorry, an error occured. Please try again later.';
                }
                       
        }
        else
        {
                echo 'All fields are required.';
        }
}
?>
<form action="index.php" method="POST">
Name:<br><input type="text" name="contact_name" maxlenght="25"><br><br>
Email address:<br><input type="text" name="contact_email" maxlenght="50"><br><br>
Message:<br>
<textarea name="contact_text" rows="6" cols="30" maxlenght="1000"></textarea><br><br>
<input type="submit" value="Send">
</form>

(Da ne bude glupo, )je l' stranica sa ovim kodom index.php ili je sejvirana pod drugim nazivom?

Btw. evo jos materijala, kazu da su rjesavali nesto slicno.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...