WordPress.org

Support

Support » How-To and Troubleshooting » Problem with php multiple choice form

Problem with php multiple choice form

  • pmalerba
    Member

    @pmalerba

    Hello everybody,
    I’m trying to make a contact form work with multiple lists within a wp page.
    I cannot use wp contact form because I need a customizable and multiple choice form.

    I created a new page template
    <?php
    /*
    Template Name: Contact form
    */
    ?>

    And I’ve got this lind of structure:

    <?php get_header(); ?>
    <div id=”container”
    <?php get_sidebar(); ?>
    <div id=”content”>
    <div class=”post”>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; endif; ?>
    </div>
    <?
    if (isset($_POST[‘submit’]) and $_POST[‘submit’]==TRUE) {
    $receiverMail = “mail@mydomain.com”;
    $name=stripslashes(strip_tags($_POST[‘name’]));
    $email=stripslashes(strip_tags($_POST[’email’]));
    $luogo=stripslashes(strip_tags($_POST[‘luogo’]));
    $subject=stripslashes(strip_tags($_POST[‘subject’]));
    $msg=stripslashes(strip_tags($_POST[‘message’]));
    $make=stripslashes(strip_tags($_POST[‘make’]));
    $ip=$_SERVER[‘REMOTE_ADDR’];
    $msgformat=”Messaggio da: $name ($ip); scrive da $luogo ; nEmail: $emailnn$msg $make $type $model $lunghezza $larghezza”;
    if(empty($name) || empty($email) || empty($subject) || empty($luogo) || empty($msg) || empty($make))
    $resp=”<h2>Il messaggio non è stato spedito</h2>Per favore compila tutti i campi.”;
    elseif(!ereg(“^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$”, $email))
    $resp=”<h2>Il messaggio non è stato spedito</h2>L’ indirizzo email non sembra valido.”;
    elseif(mail($receiverMail, $subject, $msgformat, “Da: $name <$email>”))
    $resp=”<h2>Il messaggio è stato spedito con successo</h2>Riceverai una risposta al più presto direttamente al tuo indirizzo email. Grazie per averci scelto.”;
    else $resp=”<h2>Il messaggio non è stato spedito</h2>Si sono infatti verificati problemi tecnici: ti invitiamo a riprovare più tardi.”;
    $resp=$resp.” Puoi tornare alla Home page“;
    echo $resp;
    }
    else { ?>
    <form method=”post” action=””><div id=”materiale”>
    <label for=”name”>Nome: </label>

    <input type=”text” id=”name” name=”name” size=”25″>

    <br>
    [CUT — CUT — CUT ]
    </form>
    <? } ?><
    </div> <!– Closes the content div–>
    </div>
    <!– Closes the container div–>
    <?php include(‘footer.php’); ?>

    I’m sure the form is working and I think there’s just a problem of permalink. When I try to send a request by form, the message is not sent and I get an error 404 page back.
    This question is present in the Italian forum too.

    Can anybody help me to solve this problem?

    Tnx

Viewing 2 replies - 1 through 2 (of 2 total)
  • pmalerba
    Member

    @pmalerba

    up

    jrawle
    Member

    @jrawle

    The action attribute of the form element is empty. This will post the form to the index file in the current directory, which probably isn’t this script. Put the name of the current script for the action attribute.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with php multiple choice form’ is closed to new replies.