Jump to content

anonymous email form


carley_bell

Recommended Posts

Hi,

I have a form that posts to a php file to 1) validate the user inputs and 2) get the email address associated with the row id to hide the email address from "view source". I am trying to send the form and I get the error

"Warning: mail() [function.mail]: Failed to connect to mailserver at "relay-hosting.secureserver.net" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\Host\27076321\html\processor_contact_user.php on line 20

Thank You, Your email as been sent "

I looked at the godaddy help page (http://help.godaddy.com/article/512#webformmailer) and they say I need to use this

<form action="_gdForm/webformmailer.asp" method="post">

on my form page... but then I would not be able to get the email address (I think?) I am new to mailing forms so I will post my code and shut up  :-[

<?php
include("./config.inc.php");
$row = $_POST['row'];

// makes sure there are no blank fields
if (!$_POST['from'] | !$_POST['message']) {
die('You did not complete all of the required fields. Please use your browsers back button to go back to the form');
}

// make sure email address is valid
if (!preg_match('/^[a-z0-9._-]+[a-z0-9._-]+@[a-z0-9]+[a-z0-9.-]+[a-z0-9]+.[a-z]{2,4}$/i', $_POST['from'])){
die('Invalid email address. Please use your browsers back button to go back to the form ');
}

// get email address from row number (field_7 is the email)
$query = "SELECT field_7 FROM `".$db_table."` WHERE '$row' = id";  
$result = mysql_query($query);

if ($row = $result){
    mail($row['field_7'], $_POST['subject'], $_POST['message'], "From: ".$_POST['from']);
    echo "Thank You, Your email as been sent";
  }else{
    echo "Error: Invlid User ID";
  } 
?> 

Link to comment
https://forums.phpfreaks.com/topic/142572-anonymous-email-form/
Share on other sites

When you hit the submit button it will send all $_POST[] vars to the site specified in:

 

<form action="_gdForm/webformmailer.asp" method="post">

 

From there you would just have to call the var

 

Ex.

$email = $_POST['email'];

 

Sub email with what the value of your input box was on previous page.

 

Then just set $email in the email link. All information reguarding $email, and $_POST['email'] should not be able to be viewed with source code.

 

Hope this helps :)

Link to comment
https://forums.phpfreaks.com/topic/142572-anonymous-email-form/#findComment-747177
Share on other sites

@redarrow: thanks, I missed that

 

@sudden: so I should put the <form action="_gdForm/webformmailer.asp" method="post"> on the other page (my form) and then combine the above code with the form and skip the second page for validating and replacing the email address?

Link to comment
https://forums.phpfreaks.com/topic/142572-anonymous-email-form/#findComment-747182
Share on other sites

You can intergrate the validation page w/ the site in which they input their information.

 

<?php
if(!isset($_POST['validate']){ //checks to see if they have tryed to validate their info
?>
//form goes here with action = "<?php $_SERVER['PHP_SELF'] ?>"

//fill out info

//click validate button returning a value in $_POST['validate'] button HTML below

<input type="submit" name="validate" value="Validate">

//website will reload w/ all values that were posted in the form, but the form will not be shown because of the if(!isset($_POST['validate'])) statement.

<?php
}else{

//all validation code should go here
//another form could be displayed to give another submit button after all information checks out
?>
<input type="submit" name="submit" value="Submit">

//This form should have the action below so it will post all information in the $_POST[] on the 2nd page

<form action="_gdForm/webformmailer.asp" method="post">
<?php } ?>

 

I hope this helps. :) Also there may be an easier way to do this.

 

Link to comment
https://forums.phpfreaks.com/topic/142572-anonymous-email-form/#findComment-747193
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.