Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3

Thread: Form

  1. #1
    Junior Member
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    19
    Member #
    13406
    I have a small problem with my contact form. It works, i get the emails. But after pressing submit it goes to this ugly white confirmation page. It looks bad. How could i get the browser to goto the last page after the for was submited. Back to the form page not the ugly confirmation page.
    Here is the php form im using. I dont know much about php so if anyone feels like making the change for me id appreciate it.
    PHP Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="2D2D2D">
    <?php
    define 
    ("MAX_SIZE","1000");

    function 
    getExtension($str) {
    $i strrpos($str,".");
    if (!
    $i) { return ""; }
    $l strlen($str) - $i;
    $ext substr($str,$i+1,$l);
    return 
    $ext;
    }

    $errors=0;
    if(isset(
    $_POST['Submit']))
    {
    $image=$_FILES['image']['name'];
    if (
    $image)
    {
    $filename stripslashes($_FILES['image']['name']);
    $extension getExtension($filename);
    $extension strtolower($extension);
    fileotherwize we will do more tests
    if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
    {
    echo 
    '<h1>Unknown extension!</h1>';
    $errors=1;
    }
    else
    {
    //$_FILES['image']['tmp_name'] is the temporary filename of the file in which the uploaded file was stored on the server
    $size=filesize($_FILES['image']['tmp_name']);
    if (
    $size MAX_SIZE*1024)
    {
    echo 
    '<h1>You have exceeded the size limit!</h1>';
    $errors=1;
    }
    $image_name=time().'.'.$extension;
    $newname="images/".$image_name;
    $copied copy($_FILES['image']['tmp_name'], $newname);
    if (!
    $copied)
    {
    echo 
    '<h1>Copy unsuccessfull!</h1>';
    $errors=1;
    }}}}

    if(isset(
    $_POST['Submit']) && !$errors)
    {
    echo 
    "<p>File Uploaded.</p>";
    echo 
    "<img src=\"$newname\" alt=\"\" /><br />";
    }
    ?>
    <p>&nbsp;</p>
    <table width="239" border="0" align="left" cellpadding="0" cellspacing="0" class="unnamed1">
      <!--DWLayoutTable-->
      <tr> 
        <td width="267" height="268" valign="top" class="unnamed1"><form name="form1" method="post" action="/cgi-sys/FormMail.cgi">
            <div align="center"> 
              <p align="left"><font face="Trebuchet MS">Temporary contact form. The 
                site is currently under construction. If you need to contact the webmaster 
                remember to include your email.</font><br>
                <font face="Trebuchet MS"> 
                <input name="Email:" type="text" size="20" maxlength="20">
                EMAIL </font></p>
              <p align="left"> <font face="Trebuchet MS">Type your message. 
                <textarea name="Message:" cols="35" rows="5"></textarea>
                <input type="submit" name="Sent." value="Submit">
                <input type=hidden name="recipient" value="blabla">
                </font> </p>
            </div>
          </form></td>
      </tr>
    </table>
    </body>
    </html>
    Let the rabbits wear glasses.

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    PHP Code:
    <?php
    // the above code should be as it was.
    if(isset($_POST['Submit']) && !$errors)
    {
    echo 
    "<p>File Uploaded.</p>";
    echo 
    "<img src=\"$newname\" alt=\"\" /><br />";
    } else {
    ?>
    <p>&nbsp;</p>
    <table width="239" border="0" align="left" cellpadding="0" cellspacing="0" class="unnamed1">
      <!--DWLayoutTable-->
      <tr>
        <td width="267" height="268" valign="top" class="unnamed1"><form name="form1" method="post" action="/cgi-sys/FormMail.cgi">
            <div align="center">
              <p align="left"><font face="Trebuchet MS">Temporary contact form. The
                site is currently under construction. If you need to contact the webmaster
                remember to include your email.</font><br>
                <font face="Trebuchet MS">
                <input name="Email:" type="text" size="20" maxlength="20">
                EMAIL </font></p>
              <p align="left"> <font face="Trebuchet MS">Type your message.
                <textarea name="Message:" cols="35" rows="5"></textarea>
                <input type="submit" name="Sent." value="Submit">
                <input type=hidden name="recipient" value="blabla">
                </font> </p>
            </div>
          </form></td>
      </tr>
    </table>
    <?php
    }
    ?>
    </body>
    </html>
    Should mean that if the form is nut submitted, the form isdisplayed.

    By the way, I see no form file element in your code, or did you just remove for posting easeness?

  4. #3
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    I see this line in your form:
    <input type="submit" name="Sent." value="Submit">

    and this line in your script:
    if(isset($_POST['Submit']))

    You don't have a variable called "Submit" in your form.

    Try changing this line:
    <input type="submit" name="Sent." value="Submit">

    to this:
    <input type="submit" name="Submit" value="Submit">



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:23 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com