SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Contact form problem.

    I'm on GoDaddy hosting. The website is this one - http://c3g.eu when i'm trying to send an email, nothing happens.
    *
    This is the HTML Contact Form:
    HTML Code:
    <!-- begin contact -->
                    <div id="contact"> 
                        <form id="contact-form" action="/webformmailer.php" method="post">
                            <div class="form-row">
                                <label for="name">Nombre: *</label>
                                <input type="text" name="FirstName" id="name" class="required type-text" value="" />
                            </div>
                            <div class="form-row">
                                <label for="email">E-Mail: *</label>
                                <input type="text" name="email" id="email" class="required type-text" value=""  />
                            </div>
                            <div class="form-row">
                                <label for="subject">Tema: *</label>
                                <input type="text" name="subject" id="subject" class="required type-text" value=""  />
                            </div>
                            <div class="form-row">
                                <label for="message">Mensaje: *</label>
                                <textarea name="comments" id="message" class="required type-textarea" rows="5" cols="20" placeholder="Se admiten: Fragmovies, Cámaras de muerte, Demos CS:S y CS:GO, Reviews, Comentarios, Partidas, Vídeos divertidos, todo
    							relacionado al mundillo gaming, no se admite otra cosa."></textarea>
                            </div>
                            <div class="form-row">
                                <input type="submit" id="submit" name="submit" class="button-green styled-button" value="Enviar"/>
    							<input type="hidden" name="form_order" value="alpha"/> <input type="hidden" name="form_delivery" value="hourly_digest"/> <input type="hidden" name="form_format" value="html"/>
                            </div>
                        </form> 
                    </div>
                    <!-- end contact -->


    And this is the PHP Mailer Script (from Godaddy)


    PHP Code:
    <?php

    if ( !isset($_SERVER['SPI'])) {
            die();
    }

    if (!isset(
    $_SERVER['DOCUMENT_ROOT'])) {
            echo(
    "CRITICAL: we seem to be running outside of the norm.\n");
            
    header("Location: http://".$_SERVER["HTTP_HOST"]."/");
            die(
    "CRITICAL: Document root unavailable.\n");
    }

    $request_method $_SERVER["REQUEST_METHOD"];
    if(
    $request_method == "GET") {
            
    $query_vars $_GET;
    }
    elseif (
    $request_method == "POST") {
            
    $query_vars $_POST;
    }

    reset($query_vars);
    function 
    customsort($a,$b) {
            
    // $a is array for form vars, $b is comma seperated case sensitive field order
            // this is case sensitive -- good idea to hrc that.
            
    $data = array();
            if ( 
    strstr($b,',') == FALSE )  {
                    
    $b $b.",";
            }
            
    $ordering split(',',$b);
            foreach (
    $ordering as $orderitem) {
                    if ( (
    $orderitem != null) && ($orderitem != "") ) {
                            if (isset(
    $a[$orderitem])) {
                                    
    $data[$orderitem] = $a[$orderitem];
                            }
                    }
            }
            foreach (
    $a as $key=>$val) {
                    
    $data[$key] = $a[$key];
            }
            return 
    $data;
    }

    function 
    xmlentities($string) {
            return 
    str_replace ( array('&''"'"'"'<''>'), array('&amp;''&quot;''&apos;''&lt;''&gt;'), $string);
    }

    $t date("U");

    $formhomedir preg_replace('/.*\/home\/content/','',$_SERVER['DOCUMENT_ROOT']);
    $formhomedir explode('/',$formhomedir);
    if (
    count($formhomedir) <= 4) {
            
    $formhome="/home/content/".$formhomedir[1]."/".$formhomedir[2]."/data/";
    }
    else {
            
    $formhome="/home/content/".$formhomedir[1]."/".$formhomedir[2]."/".$formhomedir[3]."/".$formhomedir[4]."/data/";
    }

    $file_order ".default";
    $file_format ".text";
    $file_interval ".15m";
    $field_order "";

    if (isset(
    $query_vars['form_order'])) {
            if (
    $query_vars['form_order'] != "alpha") {
                    
    $field_order=$query_vars['form_order'];
                    
    $file_order=".custom";
                    
    $query_vars customsort($query_vars,$field_order);
            }
            else {
                    switch (
    $query_vars['form_order']) {
                            case 
    "alpha":
                                    
    uksort($query_vars,'strnatcasecmp');
                                    
    $file_order=".alpha";
                            break;
                            default:
                                    
    $file_order=".default";
                            break;
                    }
            }
    }

    if (isset(
    $query_vars['form_format'])) {
            switch (
    $query_vars['form_format']) {
                    case 
    "csv":
                            
    $file_format ".csv";
                    break;
                    case 
    "html":
                            
    $file_format ".html";
                    break;
                    case 
    "xml":
                            
    $file_format ".xml";
                    break;
                    case 
    "text":
                    case 
    "default":
                    default:
                            
    $file_format ".text";
                    break;
            }
    }

    if (isset(
    $query_vars['form_delivery'])) {
            switch (
    $query_vars['form_delivery']) {
                    case 
    "hourly":
                            
    $file_interval ".60m";
                    break;
                    case 
    "hourly_digest":
                            
    $file_interval ".60mc";
                    break;
                    case 
    "daily":
                            
    $file_interval ".24h";
                    break;
                    case 
    "daily_digest":
                            
    $file_interval ".24hc";
                    break;
                    case 
    "digest":
                            
    $file_interval ".15mc";
                    break;
                    case 
    "default":
                    default:
                            
    $file_interval ".15m";
                    break;
            }
    }

    $file $formhome."form_".$t.$file_order.$file_format.$file_interval;
    $fp fopen($file,"w");

    reset($query_vars);
    switch (
    $file_format) {
            case 
    ".csv":
                    
    $csvkeys "";
                    
    $csvvals"";
                    
    $firsttime "";
                    while (list (
    $key$val) = each ($query_vars)) {
                            if ( (
    $key == "form_order") ||
                                    (
    $key == "form_format") ||
                                    (
    $key == "form_delivery") ||
                                    (
    $key == "redirect") ) {
                            }
                            else {
                                    if (
    $csvkeys != "") {
                                            
    $firsttime=",";
                                    }
                                    
    $tmpkey=escapeshellcmd($key);
                                    
    $csvkeys $csvkeys.$firsttime."'".$tmpkey."'";
                                    
    $tmpval=escapeshellcmd($val);
                                    
    $csvvals $csvvals.$firsttime."'".$tmpval."'";
                            }
                    }
                    
    fputs($fp,"$csvkeys\n");
                    
    fputs($fp,"$csvvals\n");
            break;
            case 
    ".html":
                    
    fputs($fp,"<table border=\"1\" cellspacing=\"1\" cellpadding=\"2\">\n");
            break;
            case 
    ".xml":
                    
    fputs($fp,"<form>\n");
            break;
    }

    reset($query_vars);
    while (list (
    $key$val) = each ($query_vars)) {
            if (
    $key == "redirect") {
                    
    $landing_page $val;
            }
            if ( (
    $key == "form_order") ||
                    (
    $key == "form_format") ||
                    (
    $key == "form_delivery") ||
                    (
    $key == "redirect") ) {

            }
            else {
                    switch (
    $file_format) {
                            case 
    ".html":
                                    
    fputs($fp,"\t<tr>\n");
                                    
    fputs($fp,"\t\t<td><b>$key</b></td>\n");
                                    
    fputs($fp,"\t\t<td>$val</td>\n");
                                    
    fputs($fp,"\t</tr>\n");

                            break;
                            case 
    ".csv":
                                    
    // content is already output
                            
    break;
                            case 
    ".xml":
                                    
    fputs($fp,"\t<field>\n");
                                    
    fputs($fp,"\t\t<fieldname>".xmlentities($key)."</fieldname>\n");
                                    
    fputs($fp,"\t\t<fieldvalue>".xmlentities($val)."</fieldvalue>\n");
                                    
    fputs($fp,"\t</field>\n");
                            break;
                            case 
    ".text":
                            default:
                                    
    fputs($fp,$key.": ".$val."\n");
                            break;
                    }
            }
    }

    switch (
    $file_format) {
            case 
    ".html":
                    
    fputs($fp,"</table>\n");
            break;
            case 
    ".xml":
                    
    fputs($fp,"</form>\n");
            break;
    }


    fclose($fp);

    if (
    $landing_page != "") {
            
    header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
    }
    else {
            
    header("Location: http://".$_SERVER["HTTP_HOST"]."/");
    }


    ?>


    Is there something wrong?

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,438
    Mentioned
    45 Post(s)
    Tagged
    13 Thread(s)
    Hi,

    I found some docs for the webformmailer.php script here, but they are quite basic. It does look like maybe you should be including a hidden field on your form:
    HTML Code:
    <input type="hidden" name="redirect" value="thankyou.html" />
    to tell the script where to redirect to after submission - you could try adding that and see if it makes a difference.

    Also, have you checked that there is a destination email address configured for the form results? http://support.godaddy.com/help/arti...hp-form-mailer

  3. #3
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,343
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    This
    Code:
    if ($landing_page != "") {
            header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
    }
    else {
            header("Location: http://".$_SERVER["HTTP_HOST"]."/");
    }
    should be the very FIRST in your code.
    As stated in the documentation, "Remember that header() must be called before any actual output is sent,..."
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  4. #4
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,438
    Mentioned
    45 Post(s)
    Tagged
    13 Thread(s)
    Quote Originally Posted by ParkinT View Post
    This
    Code:
    if ($landing_page != "") {
            header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
    }
    else {
            header("Location: http://".$_SERVER["HTTP_HOST"]."/");
    }
    should be the very FIRST in your code.
    I don't think that particular piece of code could be moved any higher in the script, as you wouldn't want to redirect before the form processing was done. Calling header() at the end of a script shouldn't be a problem, as long as you're not outputting anything before that. This section of code, near the beginning of the script, would cause an error however:
    PHP Code:
    if (!isset($_SERVER['DOCUMENT_ROOT'])) {
            echo(
    "CRITICAL: we seem to be running outside of the norm.\n");
            
    header("Location: http://".$_SERVER["HTTP_HOST"]."/");
            die(
    "CRITICAL: Document root unavailable.\n");

    as it's calling header after echoing some text.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •