Jump to content

Form that posts and emails...


kentopolis

Recommended Posts

Hey everyone, I am really new to PHP, I have a script that is working for an individual to update a dog ad on this site I built.  What I would like to have happen is not only for the data to post to the MySQL, but also for it to email me and tell me that someone has placed an ad.  I know this is probably extra simple, but I am dumb.  Please, if you could, just tell me how it would work in the script I have, what I need to ad where...  Thank you so much for your help, the people on this forum have already taught me a lot!  Here is my code, thank you so much!

<?
include('includes/includes.php');

if($_POST['add_puppy']){
	$p_date = $_POST['month']."/".$_POST['day']."/".$_POST['year'];
	if(isset($_POST['pshow'])){
		$pshow = 'y';
	}else{
		$pshow = 'n';
	}

	$sql = "insert into dogs(ptype,pstatus,avail_month,avail_day,dob_month,dob_day,qty,gender,p_pound,p_oz,p_date,price,link,p_num,address,email,name,comment,pshow)values(";
	$sql .= "'$_POST[ptype]',";
	$sql .= "'$_POST[pstatus]',";
                                $sql .= "'$_POST[avail_month]',";
                                $sql .= "'$_POST[avail_day]',";
	$sql .= "'$_POST[dob_month]',";
	$sql .= "'$_POST[dob_day]',";
	$sql .= "'$_POST[qty]',";
	$sql .= "'$_POST[gender]',";
	$sql .= "'$_POST[p_pound]',";
	$sql .= "'$_POST[p_oz]',";
	$sql .= "'$p_date',";
	$sql .= "'$_POST[price]',";
	$sql .= "'$_POST[link]',";
	$sql .= "'$_POST[p_num]',";
	$sql .= "'$_POST[address]',";
	$sql .= "'$_POST[email]',";
	$sql .= "'$_POST[name]',";
	$sql .= "'$_POST[comment]',";
	$sql .= "'$pshow')";

	mysql_query($sql);

	$top = mysql_fetch_array(mysql_query("select did from dogs order by did desc limit 1"));

	if ($_FILES['imagefile']['type'] == "image/pjpeg" || $_FILES['imagefile']['type'] == "image/jpeg"){ 
		copy ($_FILES['imagefile']['tmp_name'], "admin/uploads/$top[did].jpg") or die ("Error Uploading: Image Not Copied"); 
	} else {
		$err = "File not copied, Wrong Filetype (".$_FILES['imagefile']['name'].")"; 
	}
	/////////////
	if ($_FILES['imagefile2']['type'] == "image/pjpeg" || $_FILES['imagefile2']['type'] == "image/jpeg"){ 
		copy ($_FILES['imagefile2']['tmp_name'], "admin/uploads/a/$top[did].jpg") or die ("Error Uploading: Image Not Copied"); 
	} else {
		$err = "File not copied, Wrong Filetype (".$_FILES['imagefile2']['name'].")"; 
	}
	////////////////
	if ($_FILES['imagefile3']['type'] == "image/pjpeg" || $_FILES['imagefile3']['type'] == "image/jpeg"){ 
		copy ($_FILES['imagefile3']['tmp_name'], "admin/uploads/b/$top[did].jpg") or die ("Error Uploading: Image Not Copied"); 
	} else {
		$err = "File not copied, Wrong Filetype (".$_FILES['imagefile3']['name'].")"; 
	}
	////////////////
	if ($_FILES['imagefile4']['type'] == "image/pjpeg" || $_FILES['imagefile4']['type'] == "image/jpeg"){ 
		copy ($_FILES['imagefile4']['tmp_name'], "admin/uploads/c/$top[did].jpg") or die ("Error Uploading: Image Not Copied"); 
	} else {
		$err = "File not copied, Wrong Filetype (".$_FILES['imagefile4']['name'].")"; 
	}
	////////////////
	header("Location: thanks.html");
	exit();
}

if($_POST['cancel']){
	header("Location: cancel.html");
	exit();
}
?>
<html>
<head>
<title><?=$company?> Add Pet For Sale Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style9 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style12 {font-size: 12px}
.style14 {font-size: 12px; color: #FF0000; }
-->
</style>
</head>

<body>
<table width="100%">
<tr>
  <td align="center"><font size="4" face="Arial, Helvetica, sans-serif"><b>
  <?=$company?>
  Admin Panel</b></font></td>
</tr>
<tr>
  <td align="center">
	<span class="style9">
	<!-- Start Content -->
	<br>
	<br>
	</span>
	<form action="add_user.php" method="post" enctype="multipart/form-data" class="style9">
	<table width="780" cellpadding="2" BORDER=1 bordercolor="#C6C1D7" cellspacing="0">
		<tr bgcolor="#C6C1D7">
		  <td align="center" colspan="100%"><strong>Add New Pet</strong></td>
		</tr>
		<tr>
			<td width="139" align="right"><strong>Pets Type :</strong> </td>
		    <td width="627"><input name="ptype" type="text" size="30"> 
	      <span class="style12">(example: Yorkie) </span></td>
		</tr>
		<tr>
		  <td align="right"><strong>Your Name  :</strong> </td>
		  <td><input name="name" type="text" id="name" size="30"></td>
	  </tr>
		<tr>
		  <td align="right"><strong>Phone #:</strong> </td>
		  <td><input name="p_num" type="text" id="p_num" size="30"></td>
	  </tr>
		<tr>
		  <td align="right"><strong>Address :</strong> </td>
		  <td><input name="address" type="text" id="address" size="30"></td>
	  </tr>
		<tr>
		  <td align="right"><strong>Email :</strong> </td>
		  <td><input name="email" type="text" id="email" size="30"></td>
	  </tr>
		<tr>
			<td align="right"><strong>Gender :</strong></td>
		  <td><select name="gender">
                <option value="Male">Male</option>
                <option value="Female">Female</option>
              </select></td>
		</tr>
<tr><td align="right"><strong>Price :</strong></td>
  <td><input name="price" type="text" size="10">
    <font face="Arial, Helvetica, sans-serif"><span class="style12">(p_nums only - NEVER USE A $ - IT'S PUT IN AUTOMATICALLY)  </span></font></tr>
		<tr><td align="right"><strong>Date of Birth :</strong> </td>
		<td>Month:
              <input type="text" name="dob_month" size="10">
(example: June)   Day:
<input type="text" name="dob_day" size="2"></td>
		</tr>
		<tr>
			<td align="right"><strong>Pets Weight :</strong></td>
			<td><input type="text" name="p_pound" size="2">
			   Pounds    
                  <input type="text" name="p_oz" size="2">
                   Ounces    
			on date:
                <input type="text" name="month" size="1">
/
<input type="text" name="day" size="1">
/
<input type="text" name="year" size="1"></td>
		</tr>
		<tr><td align="right"><strong>Comments :</strong></td>
			<td><textarea name="comment" rows="3" cols="40"></textarea></td>
		</tr>
		<tr>
		  <td align="right"><strong>Link:</strong></td>
		  <td><font size="2"> <font face="Arial, Helvetica, sans-serif">
              <input name="link" type="text" size="32">
              </font></font> <font size="1" face="Arial, Helvetica, sans-serif">(format http://www.yourlink.com) </font></td>
	  </tr>

		<tr>
			<td align="right"><strong>Pets Image 1:</strong> </td>
			<td><input name="imagefile" type="file" size="40"></td>
		</tr>
		<tr>
		  <td align="right"><strong>Pets Image 2:</strong></td>
		  <td><input name="imagefile2" type="file" size="40"></td>
	  </tr>
		<tr>
		  <td align="right"><strong>Pets Image 3:</strong></td>
		  <td><input name="imagefile3" type="file" size="40"></td>
	  </tr>
		<tr>
		  <td align="right"><strong>Pets Image 4:</strong></td>
		  <td><input name="imagefile4" type="file" size="40"></td>
	  </tr>
		<tr><td align="right"> </td>
		  <td>
	      <input type="submit" name="add_puppy" value="Add New Pet">
 		      <input type="submit" name="cancel" value="Cancel">			    </td>
		</tr>
	</table>
	</form>
	<span class="style9">
	<!-- End Content -->
	</span></td>
</tr>
</table>
</body>
</html>

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.