Okay, Hello I've been trolling for years. This the first time I've ever asked for php help. Normally my questions seem so amateur when I finally find theanswer on my own. But this is making me pull my hair out. Hopefully someone can help me.
I currently have a php script that will look for a referral id in the url. If one is found..it displays the contact information of the referrer.
I have modified the script so in addition to it showing the contact information. It will also show a contact form on the "contact us page"
What I can't figure out is how to get the email address from the database into this form. Could someone take a look? When I use mail($row['email']...ect. The script will complete but the mail will not come to the email address in the database.
Here is the code:
This is config.php which looks for the id and displays the contact block and the email for on the contact page.
Code: <?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors',"on");
/*set debug to TRUE to delete cookies and test changes to the script.
set debug to FALSE to run in production environment.*/
$debug = FALSE;
// reset everything if debug is true
if ($debug) {
$_SESSION['contact_block'] = '';
setcookie('affid','',1);
$id='';
echo "Debug is ON";
die;
}
// we no longer use this cookie. Replaced by $_COOKIE['affid']
if (isset($_COOKIE['id'])) {unset($_COOKIE['id']); }
/*Logic:
If an affiliate ID was passed to the URL as a GET, grab it and do a lookup.
Otherwise, no affiliate, so display the default contact information.*/
//echo "Site is in debug mode and under test by developer but still usable. Please ignore.<br />";
if (isset($_GET['id'])) {
//echo 'Right now $_GET[ID] is '.$_GET['id']."<br />";
} else {//echo 'Right now $_GET[ID] is undefined'."<br />";
}
if (isset($_GET['id']))
{$id = $_GET['id'];}
elseif (isset($_COOKIE['affid'])) {$id = $_COOKIE['affid'];}
else {$id = 0;}
//echo "Now ID in config.php = ".$id."<br />";
$contact_block = lookup($id);
if (empty($contact_block)) {
$contact_block = '<p>United States Office: 410-727-6444</p>
<p>Costa Rica Office US Line: 410-800-4773</p>
<p>Costa Rica Office: 011-506-2778-7080</p>
<p>Toll Free: 866-466-5623 </p>';
$id = 0;}
// set a cookie
setcookie('affid', $id, time()+(3600*24*30),'/','.delpacifico.net');
$_SESSION['contact_block'] = $contact_block;
//echo 'Cookie in config.php = '.$_COOKIE['affid']."<br />";
//echo 'Final ID = '.$id."<br />";
?>
<?PHP
function lookup($id=0) {
// set default contact block in case affiliate no longer exists
$contact_block='';
if ($id > 0) {
// Establish database connection
include("project/ewcfg6.php");
$db = mysql_connect(EW_CONN_HOST,EW_CONN_USER,EW_CONN_PASS);
mysql_select_db(EW_CONN_DB);
// get the contact information
$sql = mysql_query("select * from affiliates where id = $id");
$num_rows = mysql_num_rows($sql);
if ($num_rows > 0){
while($row = mysql_fetch_array( $sql )) {
$contact_block = '<P>Name: '.$row['Name'].'<br />'.'Firm: '.$row['Firm'].'<br />'.'Phone: '.$row['Telephone'].'<br />'. '<a href="mailto:'.$row['email'].'?bcc=info@delpacifico.net">Send Email</a> </P>';
}
while($row2 = mysql_fetch_array( $sql )) { $contact_email = $row2['email'];
}
}
}
return($contact_block);
}
?>
<?PHP
$contact_form = '<form method="post" action="sendeail.php">
<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi;?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi; ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti; ?>" />
Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
<br />
Attention:<br />
<select name="attn" size="1">
<option value=" Sales n Billing ">Sales n Billing </option>
<option value=" General Support ">General Support </option>
<option value=" Technical Support ">Technical Support </option>
<option value=" Webmaster ">Webmaster </option>
</select>
<br /><br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
<br />
</form>'
?>
This is the email script that's called when the user submits the form
Code: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>
<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>n";
$badinput = "<h2>Feedback was NOT submitted</h2>n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] n
Attention: $attn n
Message: $notes n
From: $visitor ($visitormail)n
Additional Info : IP = $ip n
Browser Info: $httpagent n
Referral : $httpref n
";
$from = "From: $visitormailrn";
mail("kelbizzle@mailinator.com", $subject, $message, $from);
header( "Location: http://www.delpacifico.com/thanks.php" );
?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor; ?> ( <?php echo $visitormail; ?> )
<br />
Attention: <?php echo $attn; ?>
<br />
From:<?php echo $from; ?>
<br />
Message:<br />
<?php $notesout = str_replace("r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ;?>
<br /><br />
<a href="contact.php"> Next Page </a>
</p>
</body>
</html>
SQL Injection
In my attempts to protect my database from mySQL injection I have created another problem for myself....Currently all user inputted strings go through this function;Code: function cleanQuery($string)
Custom CMS
This is a big custom CMS script I'd like to develop and would like some help atleast figuring out where the best place to start would be.Website PagesBackstage 2 provides website pages for the
Storing user data help?
Hey Guys, I'm not use if this question is to broad but I can always give you more information if needed.I have a website where users can login which uses mysql anyway I have a little form asking some
$variable = $variable
HelloSorry if this is a really simple question but I have run out of ideas. Is there a really simple way of doing the following:$animal_dog = $something_something[$i]['animal_dog'];$animal_cat =
PHP Surveys
I really would like some advice.If you have a client come to you asking for a survey to be done with 117 questions each has 4 radio button check boxes, and a overall percentage needs to be tallyed up.
array empty
Hiya peeps,Ok here is the codes.order.phpCode: <?php if(!isset($_POST) OR empty($_POST)) { echo
function to return url
Hi,Can you guys help me giving a function that takes all the contents in a particular field and returns text and url seperately...For instance,Go:here is the linkwww.google.comit takes all the
Google voice
I currently have a form in html, but I want it in php so the information is not in the source code.It all works and when you put in the name and number it will call. When you push the call button it
passing data from one page to another
hey guysi have the follwoing code to get information from one page and place on another:(1st page) page to get info from:Code: <?php session_start();$_SESSION['data'] = "blah blah
PHP XML extraction text
I would like to extract an xml text and have that text directly echo(print) out on my web page. Here's the xml i want to extract:http://dblp.uni-trier.de/search/author?xauthor=SchekWhat I