Jump to content

Recommended Posts

I'm a bit new to PHP and I can't get my form to work. When I click "submit" is goes straight to a blank page, but in the URL bar it displays: ../action-page.php

I really hope someone can help me tackle this... I would be very thankfull!

 

This is my HTML code: (sorry for the length)

 

 

<form method="post" action="action-page.php">
<TABLE cellpadding=0 cellspacing=0 class="t0" style="vertical-align:middle;">
<TR>
    <TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Country:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="country" /></TD>
</TR>
<TR>    
    <TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Assigned product(s):</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="assigned_products" /></TD>
</TR>
<TR>
    <TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Association:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="association" /></TD>
</TR>
<TR>
    <TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Competitor (Mr/Miss/Mrs):</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="competitor" /></TD>
</TR>
<TR>
    <TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Place of employment:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="place_of_employment" /></TD>
</TR>
<TR>
    <TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Competitor’s Email:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="competitors_email" /></TD>
</TR>
<TR>
    <TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Date of birth:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="date_of_birth" /></TD>
</TR>
<TR>
    <TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Name of Cocktail:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="name_of_cocktail" /></TD>
</TR>
</TABLE>
<TABLE cellpadding=0 cellspacing=0 class="t0">
<TR>
    <TD style="width:30px;" class="tr6 td33"><P class="p6 ft6">No</P></TD>
    <TD style="width:60px;" class="tr6 td34"><P class="p7 ft6">CL.</P></TD>
    <TD style="width:290px;" class="tr6 td36"><P class="p8 ft6">Recipe</P></TD>
    <TD style="width:301px;" class="tr6 td37"><P class="p7 ft6">Brand Name</P></TD>
</TR>
<TR>
    <TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">1</P></TD>
    <TD style="width:60px;" class="tr7 td38"> <input type="text" size="3" maxlength="3" name="No 1 - CL" style="border:none;" /></TD>
    <TD style="width:290px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 1 - Recipe" style="border:none;" /></TD>
    <TD style="width:301px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 1 - Brand name" style="border:none;" /></TD>
</TR>
<TR>
    <TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">2</P></TD>
    <TD style="width:60px;" class="tr7 td38"> <input type="text" size="3" maxlength="3" name="No 2 - CL" style="border:none;" /></TD>
    <TD style="width:290px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 2 - Recipe" style="border:none;" /></TD>
    <TD style="width:301px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 2 - Brand name" style="border:none;" /></TD>
</TR>
<TR>
    <TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">3</P></TD>
    <TD style="width:60px;" class="tr7 td38"> <input type="text" size="3" maxlength="3" name="No 3 - CL" style="border:none;" /></TD>
    <TD style="width:290px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 3 - Recipe" style="border:none;" /></TD>
    <TD style="width:301px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 3 - Brand name" style="border:none;" /></TD>
</TR>
<TR>
    <TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">4</P></TD>
    <TD style="width:60px;" class="tr7 td38"> <input type="text" size="3" maxlength="3" name="No 4 - CL" style="border:none;" /></TD>
    <TD style="width:290px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 4 - Recipe" style="border:none;" /></TD>
    <TD style="width:301px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 4 - Brand name" style="border:none;" /></TD>
</TR>
<TR>
    <TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">5</P></TD>
    <TD style="width:60px;" class="tr7 td38"> <input type="text" size="3" maxlength="3" name="No 5 - CL" style="border:none;" /></TD>
    <TD style="width:290px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 5 - Recipe" style="border:none;" /></TD>
    <TD style="width:301px;" class="tr7 td38"> <input type="text" size="38" maxlength="200" name="No 5 - Brand name" style="border:none;" /></TD>
</TR>
<TR>
    <TD style="width:30px;" class="tr7 td38B"><P class="p6 ft7">6</P></TD>
    <TD style="width:60px;" class="tr7 td38C"> <input type="text" size="3" maxlength="3" name="No 6 - CL" style="border:none;" /></TD>
    <TD style="width:290px;" class="tr7 td38C"> <input type="text" size="38" maxlength="200" name="No 6 - Recipe" style="border:none;" /></TD>
    <TD style="width:301px;" class="tr7 td38C"> <input type="text" size="38" maxlength="200" name="No 6 - Brand name" style="border:none;" /></TD>
</TR>
</TABLE>
<P class="p9 ft10">Please write legibly in block letters. Maximum 6 ingredients and not more than 7cl of alcohol as base.</P>
<TABLE cellpadding=0 cellspacing=0 class="t0" style="vertical-align:middle;">
<TR>
    <TD style="width:350px; padding-bottom:10px;"><p class="p5 ft2">Garnish:</p></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Garnish" /></TD>
</TR>
<TR>    
    <TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Decoration:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Decoration" /></TD>
</TR>
<TR>
    <TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2"> </P></TD>
    <TD style="width:350px; padding-bottom:10px;"><input type="radio" name="Build-Stir-Shake-Blend" value="Build" />Build <input type="radio" name="Build-Stir-Shake-Blend" value="Stir" />Stir <input type="radio" name="Build-Stir-Shake-Blend" value="Shake" />Shake <input type="radio" name="Build-Stir-Shake-Blend" value="Blend" />Blend </TD>
</TR>
<TR>
    <TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Glass:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Glass" /></TD>
</TR>
<TR>
    <TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Contact person:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Contact person" /></TD>
</TR>
<TR>
    <TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Title:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Title" /></TD>
</TR>
<TR>
    <TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Checked and approved by Guild President:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Checked and approved by Guild President" value="(Name and signature)" onfocus="if
(this.value==this.defaultValue) this.value='';" /></TD>
</TR>
<TR>
    <TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Email:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Email" /></TD>
</TR>
<TR>
    <TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Fax/Tel:</P></TD>
    <TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Fax/Tel" /></TD>
</TR>
</TABLE>
<TABLE cellpadding=0 cellspacing=0 class="t3" style="vertical-align:middle;">
<TR>
    <TD style="width:681px; padding-bottom:10px;"><p style="font-size:15px; font:'Times New Roman'; font-style:normal;">WCC entry forms must be accompanied by a picture of the competitor, as a <strong>separate file:</strong></br></br>
<input type="file" name="userfile" />
</br></br>
<strong>- Close-up</strong> (portrait, no “action shot“)</br>
<strong>- Full-color</br>
- High resolution</strong> (at least 1Mb, but preferably higher)</p></TD>
</TR>
</TABLE>

</br></br>
<input type="submit" class="button" style="width:160px; height:47px;" value="send" />

</form>

 

 

And this is my action-page.php: (I haven't entered all the fiels from the form yet, hope that's not the problem? I wanted to check if it worked first)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Before Dinner Cocktail Competition</title>
</head>

<body>

<?php
$naar = 'info@sightdraft.nl'; // Waar moet het naartoe?
$onderwerp = 'Registration form Before Dinner Cocktail Competition'; // Het onderwerp van het bericht

// Header instellen, zodat nl2br() werkt
$headers = "MIME-version: 1.0\r\n";
$headers .= "content-type: text/html;charset=utf-8\r\n";

if(isset($_POST['send'])) // Als het formulier verzonden is door op de verzend knop te klikken
{
  $country = trim($_POST['country']); // Alle overbodige spaties uit het country veld verwijderen
  $assigned_products = trim($_POST['assigned_products']); // Alle overbodige spaties uit het assigned_products veld verwijderen
  $association = trim($_POST['association']); // Alle overbodige spaties uit het association veld verwijderen
  $competitor = trim($_POST['competitor']); // Alle overbodige spaties uit het competitor veld verwijderen
  $place_of_employment = trim($_POST['place_of_employment']); // Alle overbodige spaties uit het place_of_employment veld verwijderen
  $competitors_email = trim($_POST['competitors_email']); // Alle overbodige spaties uit het competitors_email veld verwijderen
  $date_of_birth = trim($_POST['date_of_birth']); // Alle overbodige spaties uit het date_of_birth veld verwijderen
  $name_of_cocktail = trim($_POST['name_of_cocktail']); // Alle overbodige spaties uit het name_of_cocktail veld verwijderen

  $fout = false; // Om te kijken straks of er wat fout is

  if(empty($country)) // Als het country veld niet is ingevuld
  {
    print '<p>Sorry, the "country" field is compulsory!</p>';
    $fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
  }
  if(empty($assigned_products)) // Als het assigned_products veld niet is ingevuld
  {
    print '<p>Sorry, the "assigned products" field is compulsory!</p>';
    $fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
  }
  if(empty($association)) // Als het association veld niet is ingevuld
  {
    print '<p>Sorry, the "association" field is compulsory!</p>';
    $fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
  }
    if(empty($competitor)) // Als het competitor veld niet is ingevuld
  {
    print '<p>Sorry, the "competitor" field is compulsory!</p>';
    $fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
  }
    if(empty($place_of_employment)) // Als het place_of_employment veld niet is ingevuld
  {
    print '<p>Sorry, the "place of employment" field is compulsory!</p>';
    $fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
  }
    if(empty($date_of_birth)) // Als het date_of_birth veld niet is ingevuld
  {
    print '<p>Sorry, the "date of birth" field is compulsory!</p>';
    $fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
  }
    if(empty($name_of_cocktail)) // Als het name_of_cocktail veld niet is ingevuld
  {
    print '<p>Sorry, the "name of cocktail" field is compulsory!</p>';
    $fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
  }
    if(empty($competitors_email)) // Als het competitors_email veld niet is ingevuld
  {
    print '<p>Sorry, the "competitors email" field is compulsory!</p>';
    $fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
  }
 

  if(!filter_var($competitors_email, FILTER_VALIDATE_EMAIL)) // Als het email adres niet correct is
  {
    print '<p>Sorry, the emailadress is not correct!</p>';
    $fout = true;
  }
  if(empty($bericht)) // Als het bericht veld niet is ingevuld
  {
    print '<p>Sorry, this is a compulsory field and needs to be filled!</p>';
    $fout = true;
  }

  if($fout == false) // Als er niks fout is (alles is dus netjes ingevuld)
  {
    $headers .= 'From: ' . $competitor . '<' . $competitors_email . '>'; // Een afzender instellen zodat je kan reageren.

    if(mail($naar, $onderwerp, nl2br($name_of_cocktail), $headers))
    {
      print '<p>The registration was send succesfully!</p>';
    }
    else
    {
      print '<p>Sorry, something went wrong while sending the form.</p>';
    }
  }
}
?>

</body>
</html>
Edited by Ch0cu3r
Added code tags

 

When I click "submit" is goes straight to a blank page, but in the URL bar it displays: ../action-page.php

Blank white page usually means PHP encountered an error. Either check your severs error logs or enable error reporting either in your php config or add the following lines before line 1

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
?>

NOTE: Please wrap code in


tags when posting code. I have edited your post for you.

It looks like you're testing for a submit button named "send" here:

if(isset($_POST['send']))

However, your submit button is not named. Try changing this

<input type="submit" class="button" style="width:160px; height:47px;" value="send" />

To this (note the name attribute)

<input type="submit" name="send" class="button" style="width:160px; height:47px;" value="send" />
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.