Form info not being sent

Hi folks,
I’m afraid I’m a bit of a dummy as far as PHP goes, so your help would be appreciated greatly.
I’ve just put a form on the contact page of the website and am using a contactForm.php to send the info on the form. I’m not getting any response and what I have tried to glean from the internet has confused me more.

The contact page is at:Photography and Montages by Iain Jacobs

The php info is here:

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Results from Contact form'; 

// Your email address. This is where the form information will be sent. 
$emailadd = 'iain.jacobs@gmail.com'; 

// Where to redirect after form is processed. 
$url = 'http://www.ijacobs.com/confirmation.html'; 

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '1'; 

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\
\
"; 
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\
', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?> 

If one of you could please correct or suggest a better way of getting it to work I would be very grateful.

Thanks in advance.

Can you post the form code as well?

Edit: nevermind… I went to the page you linked.

<form [B][COLOR="Red"]action="sentNotice.html"[/COLOR][/B] method="post" id="contactForm">

You are sending the form to sentNotice.html, not to contactForm.php.
Change the action.

Guido, I’ve just done that and the contactForm now appears on the screen in place of the “Thanks for sending your message etc.” page which was the sentNotice.html.

I haven’t received any message in the email, so it’s a bit worse than it was. Have you got any other ideas, or is there another way I can send the messages?

Thanks for your help.

It isn’t worse. It’s a first step towards the solution :wink:

The php code inside contactForm.php isn’t parsed by the php parser for some reason. Does your webhosting include PHP?

Yes it does, 4, 5 & 5.3 . Should I put the .php in the bin folder of their php folder. At the moment it is in my root folder.

Thanks for your patience.

I don’t know. What does your hoster say?

I’ll ask him.

Just sent off an email. They are usually pretty quick and helpful.
Maybe they will solve the whole thing.
I’ll let you know.
Thanks for leading me in the right direction.

They have told me that just putting it in the public/html folder just like all the other images & pages etc. is what to do. I’ve changed the contactForm.php from the pages folder to the html folder (my root), but nothing has changed.
Hopefully you’ve got another suggestion.
Best wishes

Can you post the entire content of contactForm.php ? Don’t forget to eliminate any sensitive info (like passwords, email addresses, etc).

Guido,
All of the contactForm.php I posted earlier. I got it from a tutorial on the net. All I have is the form page, a sent page and the contactForm.php.

As I said, being a bit of a dummy with php I just followed the tutorial and crossed my fingers.
Maybe I need another php solution? I’ll leave it in your kind hands.
Thanks

They’ve just sent me this form from the server and told me the other is full of mistakes and won’t work.

I haven’t started to fill it in yet and I have to go out unfortunately for an hour or two. I will look at it when I get back.

I hope you prefer this (although some of it is in Spanish).
Dank u

$value) { $_POST["$key"] = stripslashes($value); } } # Detect any Windows operating system # if (strstr(php_uname(), 'Windows')) { $IS_WINDOWS = TRUE; } ######################################################################## # # # USER CONFIGURABLE SETTINGS # # # ######################################################################## # Authorized email address masks that can be used as the recipient # $auth = "*@127.0.0.1, *@localhost, *@*"; // $auth = "*@127.0.0.1, *@localhost"; # Authorize all email addresses to the current domain # # If you want strict email account authorization, comment this out and # the script will only authorize the masks in the list defined above. # $auth .= ", *@" . get_domain($_SERVER['SERVER_NAME']); # Email address masks that will be rejected if in the email field # $deny = "nobody@*, anonymous@*, postmaster@*"; # The following allow you to set some default settings # # These are commented out by default and when used, either override or # append to any values. This allows you to ensure that hackers don't # post their own values to certain fields, making you miss out on # important data that you want to ensure is included in the email. # #$must['required'] = "env_report"; #$must['env_report'] = "REMOTE_ADDR"; #$must['redirect'] = "http://my.domain.com/ok.html"; #$must['error_redirect'] = "http://my.domain.com/error.html"; #$must['missing_fields_redirect'] = "http://my.domain.com/missing.html"; # ######################################################################## ######################################################################## # # # DO NOT EDIT ANYTHING PAST THIS POINT # # # ######################################################################## ######################################################################## # # Functions # # Trim leading and trailing white space from array values # function array_trim(&$value, $key) { $value = trim($value); } # Return the top level domain of a hostname # function get_domain($string) { if (eregi('\\.?([a-zA-Z0-9\\-]+\\.?[a-zA-Z0-9\\-]+)$', $string, $values)) { return $values[1]; } return NULL; } # Show an error message to the user # function error_msg($error, $required = FALSE) { global $post; if (!empty($post['missing_fields_redirect']) && $required) { header('Location: ' . $post['missing_fields_redirect']); } elseif (!empty($post['error_redirect'])) { header('Location: ' . $post['error_redirect']); } else { echo "\\r\
"; echo "\	\\r\
"; echo "\	\	\\r\
"; echo "\	\	\\r\
"; echo "\	\\r\
"; echo "\	\\r\
"; echo "\	\	

${error}
\\r\
\	\	

« volver atras
\\r\
"; echo "\	\\r\
"; echo "\\r\
"; } exit(); } # Basic pattern matching on an entire array # function pattern_grep($input, $array) { foreach ($array as $value) { $value = addcslashes($value, '^.[]$()|{}\\\\'); $value = str_replace('*', '.*', $value); $value = str_replace('?', '.?', $value); $value = str_replace('+', '.+', $value); if (eregi('^' . $value . '$', $input)) { return TRUE; } } return FALSE; } # ######################################################################## ######################################################################## # # Main # # Check to make sure the info was posted # if ($_SERVER['REQUEST_METHOD'] == 'POST') { $post = array( 'recipient' => $_POST['recipient'], 'email' => $_POST['email'], 'subject' => $_POST['subject'], 'realname' => $_POST['realname'], 'required' => $_POST['required'], 'env_report' => $_POST['env_report'], 'sort' => $_POST['sort'], 'redirect' => $_POST['redirect'], 'error_redirect' => $_POST['error_redirect'], 'missing_fields_redirect' => $_POST['missing_fields_redirect'] ); $http = array( 'REMOTE_USER' => $_SERVER['REMOTE_USER'], 'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'], 'HTTP_USER_AGENT' => $_SERVER['HTTP_USER_AGENT'] ); if (isset($must['required'])) { $post['required'] = $must['required'] . ',' . $_POST['required']; } if (isset($must['env_report'])) { $post['env_report'] = $must['env_report'] . ',' . $_POST['env_report']; } if (isset($must['redirect'])) { $post['redirect'] = $must['redirect']; } if (isset($must['error_redirect'])) { $post['error_redirect'] = $must['error_redirect']; } if (isset($must['missing_fields_redirect'])) { $post['missing_fields_redirect'] = $must['missing_fields_redirect']; } if (($auth = explode(',', $auth))) { array_walk($auth, 'array_trim'); } if (($deny = explode(',', $deny))) { array_walk($deny, 'array_trim'); } # Check for missing required fields # if ((!empty($post['required'])) && ($list = explode(',', $post['required']))) { $list[] = 'recipient'; $list[] = 'email'; array_walk($list, 'array_trim'); foreach ($list as $value) { if (!empty($value) && empty($_POST["$value"])) { error_msg("No has rellenado todos los campos obligatorios.", TRUE); } } } # Check the email addresses submitted # if (pattern_grep($post['email'], $deny)) { error_msg("Ha introducido una direccion de correo no permitida."); } if (!eregi('^([a-zA-Z0-9\\.\\_\\-]+)\\@((([a-zA-Z0-9\\-]+)\\.)+([a-zA-Z]+))$', $post['email'])) { error_msg("Ha introducido una direccion de correo no valida"); } if (!$IS_WINDOWS) { if (!getmxrr(get_domain($post['email']), $mxhost)) { error_msg("El dominio de la direccion de correo que ha introducido no tiene registro MX."); } } # Check if the recipients email address is authorized # if ((!empty($post['recipient'])) && ($list = explode(',', $post['recipient']))) { array_walk($list, 'array_trim'); foreach ($list as $value) { if (!eregi('^([a-zA-Z0-9\\.\\_\\-]+)\\@((([a-zA-Z0-9\\-]+)\\.)+([a-zA-Z]+))$', $value)) { error_msg("La direccion de correo del recipiente no es valida."); } if (!pattern_grep($value, $auth)) { error_msg("La direccion de correo del recipiente no esta autorizado."); } } } else { error_msg("Ha ocurrido un error desconocido al comprobar la validez de la direccion de correo del recipiente."); } # Sort the fields # if ((!empty($post['sort'])) && ($list = explode(',', $post['sort']))) { array_walk($list, 'array_trim'); foreach ($list as $value) { $form["$value"] = $_POST["$value"]; } } else { $form = $_POST; } # Create the message # $subject = empty($post['subject']) ? "Formulario" : "Formulario: " . $post['subject']; $message = "Enviado por: " . $post['realname'] . " <" . $post['email'] . "> con fecha " . date('l, F jS, Y @ g:i:s a (O)') . "\\r\
\\r\
"; if (!empty($post['env_report'])) { if (($list = explode(',', $post['env_report']))) { $message .= "Variables de cliente\\r\
"; $message .= "----------------\\r\
\\r\
"; array_walk($list, 'array_trim'); foreach ($list as $value) { if (array_key_exists($value, $http)) { $message .= "${value}:\\r\
" . $http["$value"] . "\\r\
\\r\
"; } } } } $message .= "Campos del Formulario\\r\
"; $message .= "------------------\\r\
\\r\
"; foreach ($form as $key => $value) { if (!array_key_exists($key, $post)) { $message .= "${key}:\\r\
${value}\\r\
\\r\
"; } } # Send out the email # if (mail($post['recipient'], $subject, $message, "From: " . $post['email'] . "\\r\
Reply-To: " . $post['email'] . "\\r\
X-Mailer: PHP FormMail")) { if (!empty($post['redirect'])) { header('Location: ' . $post['redirect']); } else { echo "\\r\
"; echo "\	\\r\
"; echo "\	\	\\r\
"; echo "\	\	\\r\
"; echo "\	\\r\
"; echo "\	\\r\
"; echo "\	\	

Muchas gracias por completar el formulario.
\\r\
\	\	

« volver atras
\\r\
"; echo "\	\\r\
"; echo "\\r\
"; } $fp = fopen('/var/log/formmail_log', 'a'); fwrite($fp, '['.date('Y/m/d H:i:s').'] formmail: to='.$post['recipient'].' from='.$post['email']); fclose($fp); } else { error_msg("Ha ocurrido un error desconocido en el envio del correo."); } } else { error_msg("Ha utilizado un metodo no valido. Debe utilizar el metodo POST en el campo ACTION de su formulario."); } # ######################################################################## ?> 

OK. I’ve made a Test Form at:
Contact
and filled out the ‘Formulario.php’ as best I can and placed it in the phpScripts folder.

On sending the form now, I’m getting my 404 without css (which in itself is rare because it works with any random non-existent Url…but that’s no problem).

How can I make the formulario.php and the form link to send off the info?

I hope I’m not trying your patience too much, I really am grateful for all this help you are giving me.

To be honest I didn’t even check your php code so far :smiley:
So it could be full of errors, but until the php code gets executed, it’s no use to worry about that.

I remember yesterday, when you put contactForm.php in the form’s action, that the page shown with the php code had a html, header and body tag. I wonder how that’s possible, if it only contained the lines with php you posted here?

Can you put this code on your host (call the file “test.php”)


<?php
  echo "hello";
?>

What does it show in your browser?

I put it in the html root, called it and it worked. ie. it said ‘hello’.
That gives me hope.

Good :slight_smile:

<form [B][COLOR="Red"]action="http://www.ijacobs.com/cgi-bin/formmail.php"[/COLOR][/B] method="post">

Where did you save formmail.php? Is the path in the form action correct?

I made a mistake. formmail doesn’t exist. It should have been

 <form action="../contactForm.php" method="post" id="contactForm">

I just uploaded an amended version, but still get 404 without Css.

I’m off for lunch now, so I’ll be back in about 40 mins.
Dank u

On the test page the code is

<form action="http://www.ijacobs.com/cgi-bin/formulario.php" method="post">

So if it should be ‘contactForm.php’ then it won’t work :slight_smile:
Anyway, my guess is it should be without the ‘/cgi-bin’ in the path.

Right, to avoid confusing both you and me, I have deleted all the old form stuff, which leaves the Contact page, but with the newer form (I’ll attend to its css later Photography and Montages by Iain Jacobs and formulario.php which I have put in the root folder. The contact page is in the Pages folder.

When I leave the ‘cgi-bin’ in the code, I get the 404 without css. When I take it out (which is as it is now on the server) the formulario.php shows.

Hope that helps you to assess my predicament.
Thanks

The code they sent you isn’t complete. The beginning is missing, it starts somewhere in the middle of a line of code.

First of all, the php code should be preceded by <?php
Try adding it, although then you should get errors.

‘Parse error: syntax error, unexpected ‘)’ in /home/ix/public_html/formulario.php on line 2’

I’ve asked the server people to give me a full copy of the code.

Well, something’s happening and with your kind help I think we are getting ever closer.
Right?!
Best wishes