Jump to content

whats wrong with my mailer script?


aladiyat23

Recommended Posts

I searched the forum for a previous thread and couldnt find one, i apologize if it seems repetitive...

after hitting submit, my form goes to the php mailer script (datasubmit.php) but then just stops.
this form is stripped of all validation and error checks... i attached it here, can anyone help?

I should add that this script worked perfectly for another form, but I needed it for a new client and modified it. The only thing I changed was the custom info for the form fields... (i.e., $email, $to... etc.)

Thank u in advance :)

[attachment deleted by admin]
Link to comment
Share on other sites

Your variables defined after post in datasubmit, all start with a number - thats not allowed.
From the manual --> http://no2.php.net/manual/en/language.variables.php:
[quote]A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.[/quote]

So, you should change them to start with f.example an underscore, instead of all those lines like:

[color=blue]  $1 = $_POST['1'];
  $2 = $_POST['2'];
  $3 = $_POST['3'];
  $4 = $_POST['4'];
  $5 = $_POST['5'];
  $6 = $_POST['6'];
  $7 = $_POST['7'];[/color]

You could replace all of that (from line 7 to 84) with this:
[code]

<?php
 
foreach($_POST as $key => $value)
{
  $key = "_".$key; // add underscore to each posted variable number
  ${$key} = $value; // define them, becomes $_1 = "value of 1"; etc.
}

$email = $_8;

?>

[/code]

and altering each variable down the script where you are using them, to include an underscore first.

Hope you follow me here... It might be additional problems with your code exept this one that i havent spotted though
Link to comment
Share on other sites

ok I changed the variables from just numbers... I didnt exactly follow what you said, I know I did it the hard way and just went thru and added an underscore on each.

Now the script goes thru to the 'thank you' page, but i dont receive the email.

This is frustrating! It worked perfect for another project, all I did was change these variables. Any more advice? I attached the updated scripts...

[attachment deleted by admin]
Link to comment
Share on other sites

add this at the very top in the php file:
[code]
<?php

error_reporting(E_ALL);

// rest as it is
[/code]

and adjust this part:
[code]

mail($to, $subject, $message, $headers);
echo '<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=http://www.aquagirl.org/wcf/success.asp">';

[/code]

to:
[code]

$send = mail($to, $subject, $message, $headers);

if($send)
{
  echo "Mail returned true and should be on the way";
  //echo '<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=http://www.aquagirl.org/wcf/success.asp">';
}
else
{
  echo "Mail returned false: ".$send;
}

[/code]

See what you get
Link to comment
Share on other sites

woooah... ok, here are the errors that came up:

Notice: Undefined index: _10 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 18

Notice: Undefined index: _15 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 23

Notice: Undefined index: _16 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 24

Notice: Undefined index: _17 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 25

Notice: Undefined index: _18 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 26

Notice: Undefined index: _20 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 28

Notice: Undefined index: _21 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 29

Notice: Undefined index: _31 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 39

Notice: Undefined index: _35 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 43

Notice: Undefined index: _38 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 46

Notice: Undefined index: _39 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 47

Notice: Undefined index: _40 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 48

Notice: Undefined index: _41 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 49

Notice: Undefined index: _44 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 52

Notice: Undefined index: _46 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 54

Notice: Undefined index: _48 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 56

Notice: Undefined index: _49 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 57

Notice: Undefined index: _50 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 58

Notice: Undefined index: _51 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 59

Notice: Undefined index: _56 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 64

Notice: Undefined index: _61 in d:\inetpub\aquagirl\WCF\datasubmit.php on line 69

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in d:\inetpub\aquagirl\WCF\datasubmit.php on line 191
Mail returned false:
Link to comment
Share on other sites

ok, thanks for all your help...

And for me to understand it better... i ran phpinfo() and found the SMTP info, so I see what needs to be changed but I cant get to the php.ini file. This server is also ran by someone thats running a hundred other accounts from there. I dont have control panel access or anything. They didnt even know about php when I called. SOOOO, I'm trying to understand further by googling and all that crap.

What would you do? Is there a way to host the script elsewhere but run the form from there?
Link to comment
Share on other sites

I'm on rather thin ice here since php config is a foggy area for me, you could try something like this and see what u get:
[code]

<?php

  ini_set("SMTP","mail.yourdomain.com");
  ini_set("smtp_port","25");
  ini_set("sendmail_from","fromYou@yourdomain.com");
 
  $send = mail($to, $subject, $message, $headers);

  ini_restore();

?>

[/code]
Link to comment
Share on other sites

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.