Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Undefined variable: error's just started showing up

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #149182
    Steven Gardner
    Participant

    A client just got in touch asking me to fix his contact form. This site hasn’t been edited for many months, so I can’t work out why this has just started to be an issue.

    I’m the only one who can change the code and I definitely haven’t edited anything.

    I’m no PHP developer so I’m finding it hard to solve the problem.

    I would love if someone can offer a suggestion or solution.

    http://www.exquisitelimousines.co.uk/contact.php

    Thanks for looking.

    #149186
    Alen
    Participant

    PHP is server side scripting language. We need to see the actual code of contact.php.

    #149190
    Steven Gardner
    Participant
    <?php
                // email was successfully send
                if (($form_submitted) && (!$error)) {
            ?>
                                      <!-- display submitted data -->
                                      ---------------------------------------------------<br />
                                      Thank you for your feedback, <?php echo $name; ?>.
                                      This is the information you submitted:<br>
                                      <br>
                                      <?php echo nl2br(stripslashes($msg)); ?>
                                      <?php 
                }
                // display contact form
                else {
                    // display error message
                    if ($error) {   
                        echo "<font class='form_check'>" . $error_msg . "</font>\n";
                    } 
            ?>
    
    #149191
    Steven Gardner
    Participant
    <form action="<?php echo $PHP_SELF; ?>" method="post" name="contact">
            <table border="0" width="100%" cellspacing="5" cellpadding="0">
                <tr>
                    <td class="form" width="50%">
                        <span class="details">Full Name<span class="style3">*</span></span><br>
                        <input name="name" type="text" value="<?php echo $name ?>" size="40">                   </td>
                    <td class="form">
                        <span class="details">Date of Hire</span><br>
                        <input name="date" type="text" id="Date of Hire" value="<?php echo $date ?>" size="30">                 </td>
                </tr>
            </table>
            <table border="0" width="100%" cellspacing="5" cellpadding="0">
                <tr>
                    <td width="50%" valign="top" class="form">
                        <span class="details">E-mail Address</span><br>
                        <input name="email" type="text" value="<?php echo $email ?>" size="40">                 </td>
                    <td class="form">
                        <span class="details">Phone Number</span><span class="style3">*</span><br>
                        <input name="phone" type="text" value="<?php echo $phone ?>" size="30">                 </td>
                </tr>
                <tr>
                  <td width="50%" valign="top" class="form"><span class="details">Number of Seats Needed </span><br />
                    <select name="seats" id="seats" <?php echo $seats ?>>
                      <option value="1" selected="selected">1</option>
                      <option value="2">2</option>
                      <option value="3">3</option>
                      <option value="4">4</option>
                      <option value="5">5</option>
                      <option value="6">6</option>
                      <option value="7">7</option>
                      <option value="8">8</option>
                      <option value="--">-- + 8 Requires 2 cars --</option>
                      <option value="9">9</option>
                      <option value="10">10</option>
                      <option value="11">11</option>
                      <option value="12">12</option>
                      <option value="13">13</option>
                      <option value="14">14</option>
                      <option value="15">15</option>
                      <option value="16">16</option>
                      <option value="16+">16+</option>
                    </select>                  </td>
                  <td class="form"><span class="details">Mobile Number</span><br />
                    <input name="mobile" type="text" id="mobile" value="<?php echo $mobile ?>" size="30" /></td>
              </tr>
            </table>
            <table border="0" width="100%" cellpacing="5" cellpadding="0">
                <tr>
                  <td class="form" width="50%">
                        <span class="details">How did you find us</span><br>
                        <select name="advert" id="advert" value="<?php echo $advert ?>">
                          <option>Choose One</option>
                          <optgroup label="Search Engine">
                          <option value="google">Google</option>
                          <option value="yahoo">Yahoo!</option>
                          <option value="msn">MSN Search</option>
                          <option value="aol">AOL Search</option>
                          <option value="yell.com">Internet Yellow Pages</option>
                          <option value="other_search">Other Search Engine - Indicate Below</option>
                          </optgroup>
                          <optgroup label="Other">
                          <option value="friend">Friend</option>
                          <option value="yellow_pages">Yellow Pages</option>
                          <option value="web_link">Website Link - Indicate Below</option>
                          <option value="poster_leaflet">Poster or Leaflet</option>
                          <option value="other">Other - Indicate Below</option>
                          </optgroup>
                        </select></td>
    
                <td width="50%" valign="top" class="form"><span class="details">Type of car</span><br />
                <select name="car" id="car" <?php echo $car ?>>
                      <option value="pink" selected="selected">Pink</option>
                      <option value="black">Black</option>
                    </select>                  </td>
                </tr>
            </table>
            <table border="0" width="100%" cellspacing="5" cellpadding="0">
                <tr>
                    <td class="form">
                        <span class="details">Please provide us with any other information or special requests</span><br>
                        <textarea name="message" cols="88" rows="12"><?php echo $message ?></textarea>                  </td>
                </tr>
            </table>
            <table border="0" width="100%" cellspacing="5" cellpadding="0">
                <tr>
                    <td class="form">
                    <input name="submit" type="submit" value="Send Message" onClick="pageTracker._trackPageview('/click/form-submit');">
                    </td>
                </tr>
            </table>
                                    </form>
    
    #149192
    Steven Gardner
    Participant
    <?php
                }
            ?>  
    
    #149193
    JamesBarnsley
    Participant

    That PHP code you have shown us cannot possibly be the whole of Contact.php we need to see all of the code in Contact.php

    #149194
    Steven Gardner
    Participant

    Its been so long since I looked at this code. Sorry for the delay. __

    #149195
    JamesBarnsley
    Participant

    If you want the cheap way around this, you can turn off the notice errors putting this at the very top of contact.php before any other code …

    <?php error_reporting(E_ALL ^ E_NOTICE); ?>

    That will turn off those notice errors, notice errors are not really critical errors. Your host must have changed your default PHP error settings at some point that is why those errors are appearing. If you paste that line of code at the very top of the file that will turn the errors off.

    #149198
    Steven Gardner
    Participant

    I guess the severs must have been changed or settings on them as I haven’t edited anything to do with this site in many many months.

    Thanks I will just turn off the notices as I guess its been working for a while.

    Here is the other code

    <?php
    

    $source = $_REQUEST[‘Howdidyouhereaboutus?’] ; $hiretype = $_REQUEST[‘hiretype’] ; $month = $_REQUEST[‘month’]; $day = $_REQUEST[‘day’]; $year = $_REQUEST[‘year’]; $arrivaltime = $_REQUEST[‘arrivaltime’]; $courteous = $_REQUEST[‘courteous’]; $cleanlimo = $_REQUEST[‘cleanlimo’]; $useagain = $_REQUEST[‘useagain’]; $whynot = $_REQUEST[‘whynot’]; $name = $_REQUEST[‘name’]; $value = $_REQUEST[‘value’]; $serviceproblems = $_REQUEST[‘serviceproblems’]; $improvements = $_REQUEST[‘improvements’];

    mail ("e********@email.com", "Feedback Form Results", 
    "How did you here about us? $source",
    "Type of Hire: $hiretype",
    "Date: $month $day $year",
    "When did the chauffeur arrive: $arrivaltime",
    "Was the driver courteous: $courteous",
    "How clean was the limo: $cleanlimo",
    "Would you use Exquisite Limousines again: $useagain",
    "If not why not: $whynot",
    "Name of Party: $name",
    "Was the service value for money: $value",
    "If you selected anything less than average, tell us why: $serviceproblems",
    "How could we improve the service: $improvements";
    
    header( "Location: http://www.exquisitelimousines.co.uk/thankyou.html");
    

    ?>

    #149203
    Alen
    Participant

    Do not suppress errors when you haven’t solved the issue. Look at the form fields on the page, there are bunch of errors, suppressing error reporting is not

    the cheap way around this

    I’m not sure if this forum is stripping some code. So use https://gist.github.com/ or http://codepen.io/pen/ to copy contents of contact.php so I can copy/paste and look at it in my editor.

    #149204
    JamesBarnsley
    Participant

    Well I guess if your willing to fix those bugs for free that would be the cheaper alternative.

    “Look at the form fields on the page, there are bunch of errors” – yes and they are all “notice” errors if they where real errors it would be a different story.

    It is the default PHP setting. Taken from php.net …

    // Report all errors except E_NOTICE
    // This is the default value set in php.ini
    error_reporting(E_ALL ^ E_NOTICE);

    Next you are going to come out how fixing the notices ensures optimized and efficient code that will ensure the future success of the web application to scale to millions of users etc. But is this relevant on a PHP contact form on a site that probably gets no more than a couple of contact emails a month?

    And for a client that probably paid no more than $500 for a website?

    #149205
    Alen
    Participant

    What are you talking about?

    This is not a notice. It’s an error. Error that could will cost this business money.

    This has nothing to do with scaling, or efficient code…

    #149206
    JamesBarnsley
    Participant

    I see no errors on that page only notices. Here is one of them …

    Notice: Undefined index: submit in /home/exquisit/public_html/contact.php on line 46

    They all have notice in front, so they are not real errors. The code can function perfectly fine if they are suppressed.

    #149207
    Alen
    Participant

    From your perspective these might be “notices” but from the customers perspective (and after trying to submit form)… it’s an error.

    #149208
    JamesBarnsley
    Participant

    The message after the submission is still a notice and will be corrected by suppressing the notices like I said.

Viewing 15 posts - 1 through 15 (of 21 total)
  • The forum ‘Back End’ is closed to new topics and replies.