Need help with coding report table! not able to send to email.

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 1384 Views - Last Post: 17 September 2014 - 12:00 PM Rate Topic: -----

#1 [email protected]   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 11
  • Joined: 15-September 14

Need help with coding report table! not able to send to email.

Posted 15 September 2014 - 10:46 PM

Hi , I run a website for my company and i am having issues making a report table for customers and employees to report an issue without them using their email! by simply going to our website and posting on our report table! i got most of the coding correctly and it looks great on the website but now i am having issues with the table not sending to my email! can anyone help me with what i am doing wrong? gcoc.ca/staff.html this is what the table looks like in code.
<!-- BEGIN FORM -->
	<form id="tellusform" name="tellusform" method="post" action="/php/tellus_submit.php">
	<table width="600px" align="center">
	
	<!-- Store Location -->
		<tr>	
			<td align="right" valign="center">
				<label for="Store Location">Store Location </label>
			</td>
			<td align="left" valign="top">
				<input type="text" name="name" size="30">
			</td>
		</tr>	

<!-- Employee NAME of issue -->
		<tr>	
			<td align="right" valign="center">
				<label for="employee name of issue">Name of employee with issue! </label>
			</td>
			<td align="left" valign="top">
				<input type="text" name="name" size="30">
			</td>
		</tr>	
	
		
		
	<!-- DATE -->
		<tr>	
			<td align="right" valign="center">
				<label for="date">Date of Issue or Idea (MM/DD/YYYY): </label>
			</td>
			<td align="left" valign="top">
				<input type="date" name="date" size="30">
			</td>
		</tr>
		
	
				
		
	<!-- COMMENTS -->
		<tr>	
			<td align="right" valign="top">
				<br><label for="comments">Comments: </label>
			</td>
			<td align="left" valign="top">
				<br><textarea id="comments" name="comments" cols="40" rows="5"></textarea>
			</td>
		</tr>
		
	<!-- SUBMIT -->
		<tr>
			<td colspan="2" align="center"><div align="center">
				<input type="submit" value="Submit">
				<input name="recipient" type="hidden" id="recipient" value="[email protected]">
				
			</div></td>
		</tr>
	
	</table>


and this is what should allow it to send to my email if i am correct
<?php

//ESTABLISHING
	$name = $_POST['name'];
	$age = $_POST['age'];
	$date = $_POST['date'];
	$inv = $_POST['inv'];
	$speed = $_POST['speed'];
	$clean = $_POST['clean'];
	$friend = $_POST['friend'];
	$knowledge = $_POST['knowledge'];
	$visit = $_POST['visit'];
	$comments = $_POST['comments'];	

//BUILDING MESSAGE
	$message = "Review details below. \n\n";
	$message .= "Name: " . $name;
	$message .= "\r\n Age: " . $age;
	$message .= "\r\n Date: " . $date;
	$message .= "\r\n Invoice#: " . $inv;
	$message .= "\r\n\n Speed: " . $speed;
	$message .= "\r\n Cleanliness: " . $clean;
	$message .= "\r\n Friendliness: " . $friend;
	$message .= "\r\n Knowledge: " . $knowledge;
	$message .= "\r\n Overall: " . $visit;
	$message .= "\r\n\n Comments: \r\n" . $comments;
		
		
//REDIRECT
	if(mail('[email protected]', 'Customer review!' ,$message))
		{
			header('Location: ../index.php?p=sent');
		}
	else
		{ 
		header('Location: ../index.php?p=bad');
		}

?>

This post has been edited by andrewsw: 16 September 2014 - 03:51 AM
Reason for edit:: Use CODE tags, not quote tags


Is This A Good Question/Topic? 0
  • +

Replies To: Need help with coding report table! not able to send to email.

#2 astonecipher   User is offline

  • Enterprise Software Architect
  • member icon

Reputation: 3151
  • View blog
  • Posts: 11,956
  • Joined: 03-December 12

Re: Need help with coding report table! not able to send to email.

Posted 16 September 2014 - 03:47 AM

1 your using a table. There is not a need to use tables for layouts anymore.

Where does the form end? There is an opening tag, but not a closing tag, unless you just didn't copy that over.
Was This Post Helpful? 1
  • +
  • -

#3 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6905
  • View blog
  • Posts: 28,569
  • Joined: 12-December 12

Re: Need help with coding report table! not able to send to email.

Posted 16 September 2014 - 04:11 AM

There are a number of errors in your html. In particular, you have two inputs with the same name of "name" and you don't have all the named-inputs that you are trying to read in the $_POST array.

Please don't end all your sentences with exclamation points! It isn't that exciting!
Was This Post Helpful? 1
  • +
  • -

#4 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3837
  • View blog
  • Posts: 13,998
  • Joined: 08-August 08

Re: Need help with coding report table! not able to send to email.

Posted 16 September 2014 - 08:06 AM

I have to say that it's very disappointing to see anyone who is paid as a developer post code you might expect to see from some one just a few days into learning the languages. I suggest you spend many days studying the tutorials in PHP and HTML.
Was This Post Helpful? 1
  • +
  • -

#5 [email protected]   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 11
  • Joined: 15-September 14

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 08:50 AM

View Postandrewsw, on 16 September 2014 - 04:11 AM, said:

There are a number of errors in your html. In particular, you have two inputs with the same name of "name" and you don't have all the named-inputs that you are trying to read in the $_POST array.

Please don't end all your sentences with exclamation points! It isn't that exciting!


Their is a good reason for that, I have more then 2 tables on my website which i had someone code for me when i had no time to do my self. Only now i notice they didn't work when i started to make a new table for my employee to make their own report with other staff members. I will give you the full layout with all 3 tables in pm.


View PostCTphpnwb, on 16 September 2014 - 08:06 AM, said:

I have to say that it's very disappointing to see anyone who is paid as a developer post code you might expect to see from some one just a few days into learning the languages. I suggest you spend many days studying the tutorials in PHP and HTML.


you are correct my friend reason why i fired the guy who used to handle my website! and i know how to do my own website to the point if i need to edit or make new pages. So stop been a smart A** go post on some one else post. I run a company i have no time to read. if you want to help then please do if you don't then don't bother replying to this. Thank you.
Was This Post Helpful? -3
  • +
  • -

#6 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6905
  • View blog
  • Posts: 28,569
  • Joined: 12-December 12

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 09:00 AM

Quote

I will give you the full layout with all 3 tables in pm.

Do not send me PMs about forum questions, post information here.
Was This Post Helpful? 0
  • +
  • -

#7 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 09:03 AM

Quote

So stop been a smart A** go post on some one else post. I run a company i have no time to read.

Knock it off with the personal attacks.
Was This Post Helpful? 0
  • +
  • -

#8 [email protected]   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 11
  • Joined: 15-September 14

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 09:18 AM

View Postandrewsw, on 17 September 2014 - 09:00 AM, said:

Quote

I will give you the full layout with all 3 tables in pm.

Do not send me PMs about forum questions, post information here.


No problem sorry

View Postmacosxnerd101, on 17 September 2014 - 09:03 AM, said:

Quote

So stop been a smart A** go post on some one else post. I run a company i have no time to read.

Knock it off with the personal attacks.


And didn't he personal attack me for no reason to begin with? he shouldn't go off topic to begin with. But i am sorry.


I am having a tough time because i never did php like this before. Last time i did anything like this was 6 years ago! point been said. i got 3 tables


Table on the home page
<!-- BEGIN FORM -->
<form id="tellusform" name="tellusform" method="post" action="./php/tellus_submit.php">
<table width="600px" align="center">

<!-- NAME -->
<tr>
<td align="right" valign="center">
<label for="name">Name: </label>
</td>
<td align="left" valign="top">
<input type="text" name="name" size="30">
</td>
</tr>

<!-- AGE -->
<tr>
<td align="right" valign="center">
<label for="age">Age: </label>
</td>
<td align="left" valign="top">
<select name="age" size="1" id="age">
<option selected>Under 18</option>
<option>18-24</option>
<option>25-34</option>
<option>35-44</option>
<option>Over 44</option>
</select>
</td>
</tr>

<!-- DATE -->
<tr>
<td align="right" valign="center">
<label for="date">Date of Service (MM/DD/YYYY): </label>
</td>
<td align="left" valign="top">
<input type="date" name="date" size="30">
</td>
</tr>

<!-- INVOICE -->
<tr>
<td align="right" valign="center">
<label for="inv">Invoice #: </label>
</td>
<td align="left" valign="top">
<input type="text" name="inv" size="30">
</td>
</tr>

<tr>
<td colspan="2" align="center"><div align="center">
<br><b>Please rate the following from 1(Worst) to 5(Best):</b>
</td>
</tr>

<!-- SPEED -->
<tr>
<td align="right" valign="center">
<label for="speed">Speed: </label>
</td>
<td align="left" valign="top">
<input type="radio" name="speed" value="1"> 1
<input type="radio" name="speed" value="2"> 2
<input type="radio" name="speed" value="3"> 3
<input type="radio" name="speed" value="4"> 4
<input type="radio" name="speed" value="5"> 5
</td>
</tr>

<!-- CLEAN -->
<tr>
<td align="right" valign="center">
<label for="clean">Cleanliness: </label>
</td>
<td align="left" valign="top">
<input type="radio" name="clean" value="1"> 1
<input type="radio" name="clean" value="2"> 2
<input type="radio" name="clean" value="3"> 3
<input type="radio" name="clean" value="4"> 4
<input type="radio" name="clean" value="5"> 5
</td>
</tr>

<!-- FRIEND -->
<tr>
<td align="right" valign="center">
<label for="friend">Friendliness: </label>
</td>
<td align="left" valign="top">
<input type="radio" name="friend" value="1"> 1
<input type="radio" name="friend" value="2"> 2
<input type="radio" name="friend" value="3"> 3
<input type="radio" name="friend" value="4"> 4
<input type="radio" name="friend" value="5"> 5
</td>
</tr>

<!-- KNOWLEDGE -->
<tr>
<td align="right" valign="center">
<label for="knowledge">Knowledge: </label>
</td>
<td align="left" valign="top">
<input type="radio" name="speed" value="1"> 1
<input type="radio" name="knowledge" value="2"> 2
<input type="radio" name="knowledge" value="3"> 3
<input type="radio" name="knowledge" value="4"> 4
<input type="radio" name="knowledge" value="5"> 5
</td>
</tr>

<!-- VISIT -->
<tr>
<td align="right" valign="center">
<label for="visit">Overall: </label>
</td>
<td align="left" valign="top">
<input type="radio" name="visit" value="1"> 1
<input type="radio" name="visit" value="2"> 2
<input type="radio" name="visit" value="3"> 3
<input type="radio" name="visit" value="4"> 4
<input type="radio" name="visit" value="5"> 5
</td>
</tr>

<!-- COMMENTS -->
<tr>
<td align="right" valign="top">
<br><label for="comments">Comments: </label>
</td>
<td align="left" valign="top">
<br><textarea id="comments" name="comments" cols="40" rows="5"></textarea>
</td>
</tr>

<!-- SUBMIT -->
<tr>
<td colspan="2" align="center"><div align="center">
<input type="submit" value="Submit">
<input name="recipient" type="hidden" id="recipient" value="[email protected]">
<input name="redirect" type="hidden" id="redirect" value="http://www.gcoc.ca">
</div></td>
</tr>

</table>
</form>




</div><!-- .column (end) -->







Table on the contact us
<p><!-- BEGIN FORM -->
<form id="contact" name="contact" method="post" action="./php/form_submit.php">
<table width="600px" align="left">

<!-- NAME -->
<tr>
<td align="right" valign="center">
<label for="name">Name: </label>
</td>
<td align="left" valign="center">
<input type="text" name="name" size="50">
</td>
</tr>

<!-- E-MAIL -->
<tr>
<td align="right" valign="center">
<label for="email">E-mail: </label>
</td>
<td align="left" valign="top">
<input type="email" name="email" size="50">
</td>
</tr>

<!-- PHONE -->
<tr>
<td align="right" valign="center">
<label for="phone">Phone Number: </label>
</td>
<td align="left" valign="top">
<input type="text" name="phone" size="50">
</td>
</tr>

<!-- COMMENTS -->
<tr>
<td align="right" valign="top">
<BR><label for="comments"><B>Comments:</B></label>
</td>

<td align="left" valign="top">
<BR><textarea id="comments" name="comments" cols="50" rows="10"></textarea>
</td>
</tr>

<!-- SUBMIT -->
<tr>
<td colspan="2" align="center"><div align="center">
<input type="submit" value="Submit">
<input name="recipient" type="hidden" id="recipient" value="[email protected]">
<input name="redirect" type="hidden" id="redirect" value="http://www.gcoc.ca">
</div></td>
</tr>

</table>
</form></p>
<BR><BR><BR><BR><BR><BR><BR<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
</div>


<div class="clear"></div>

<!-- HOMEPAGE COLUMNS (end) -->

</div><!-- #homepage (end) -->[/quote]


[b]My new table [/b]
[quote]<!-- BEGIN FORM -->
<form id="tellusform" name="tellusform" method="post" action="./php/tellus_submit.php">
<table width="600px" align="center">

<!-- Store Location -->
<tr>
<td align="right" valign="center">
<label for="Store Location">Store Location </label>
</td>
<td align="left" valign="top">
<input type="text" name="name" size="30">
</td>
</tr>

<!-- Employee NAME of issue -->
<tr>
<td align="right" valign="center">
<label for="employee name of issue">Name of employee with issue! </label>
</td>
<td align="left" valign="top">
<input type="text" name="name" size="30">
</td>
</tr>



<!-- Date of Issue or Idea -->
<tr>
<td align="right" valign="center">
<label for="Date of Issue or Idea ">Date of Issue or Idea (MM/DD/YYYY): </label>
</td>
<td align="left" valign="top">
<input type="date" name="date" size="30">
</td>
</tr>




<!-- COMMENTS -->
<tr>
<td align="right" valign="top">
<br><label for="comments">Comments: </label>
</td>
<td align="left" valign="top">
<br><textarea id="comments" name="comments" cols="40" rows="5"></textarea>
</td>
</tr>

<!-- SUBMIT -->
<tr>
<td colspan="2" align="center"><div align="center">
<input type="submit" value="Submit">
<input name="recipient" type="hidden" id="recipient" value="[email protected]">

</div></td>
</tr>

</table>
</form>




</div><!-- .column (end) -->



This is the php file what should i do
<?php

//ESTABLISHING
$name = $_POST['name'];
$age = $_POST['age'];
$date = $_POST['date'];
$inv = $_POST['inv'];
$speed = $_POST['speed'];
$clean = $_POST['clean'];
$friend = $_POST['friend'];
$knowledge = $_POST['knowledge'];
$visit = $_POST['visit'];
$comments = $_POST['comments'];

//BUILDING MESSAGE
$message = "Review details below. \n\n";
$message .= "Name: " . $name;
$message .= "\r\n Age: " . $age;
$message .= "\r\n Date: " . $date;
$message .= "\r\n Invoice#: " . $inv;
$message .= "\r\n\n Speed: " . $speed;
$message .= "\r\n Cleanliness: " . $clean;
$message .= "\r\n Friendliness: " . $friend;
$message .= "\r\n Knowledge: " . $knowledge;
$message .= "\r\n Overall: " . $visit;
$message .= "\r\n\n Comments: \r\n" . $comments;


//REDIRECT
if(mail('[email protected]', 'Customer review!' ,$message))
{
header('Location: ./index.php?p=sent');
}
else
{
header('Location:./index.php?p=bad');
}

?>




would be really great full if someone would help me out thank you

This post has been edited by modi123_1: 17 September 2014 - 09:22 AM
Reason for edit:: please use the 'code' button for code, and not the quote button

Was This Post Helpful? 0
  • +
  • -

#9 [email protected]   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 11
  • Joined: 15-September 14

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 09:29 AM

ty modi
Was This Post Helpful? 0
  • +
  • -

#10 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 09:31 AM

The mail() function returns true if the message was sent to the server for delivery. It does not guarantee that the server will actually send the message. Try checking /var/log/mail to see if there is any indication of a problem. Also, check that your server is configured for SMTP.

Quote

And didn't he personal attack me for no reason to begin with? he shouldn't go off topic to begin with...I am having a tough time because i never did php like this before. Last time i did anything like this was 6 years ago!

Then the suggestion of some reading material and tutorials isn't off-topic. Your form and pages are small, right now. Poor coding practices early on can come back to bite you later. Better to learn to do things the right way the first time.
Was This Post Helpful? 0
  • +
  • -

#11 [email protected]   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 11
  • Joined: 15-September 14

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 09:41 AM

View Postmacosxnerd101, on 17 September 2014 - 09:31 AM, said:

The mail() function returns true if the message was sent to the server for delivery. It does not guarantee that the server will actually send the message. Try checking /var/log/mail to see if there is any indication of a problem. Also, check that your server is configured for SMTP.



not sure "/var/log/mail" would be located! but yes SMTP is configured
Was This Post Helpful? 0
  • +
  • -

#12 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 09:42 AM

You'll want to poke around on the server for the logs. You're looking for the mail logs, in particular.
Was This Post Helpful? 0
  • +
  • -

#13 [email protected]   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 11
  • Joined: 15-September 14

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 09:44 AM

Thanks but besides that how is the coding? I simply want a table which customers don't need to use their email but let us know whats on their mind same thing with the employee
Was This Post Helpful? 0
  • +
  • -

#14 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2768
  • View blog
  • Posts: 8,077
  • Joined: 15-January 14

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 10:07 AM

The code is pretty basic. There are several things you could add, for example you're not doing any form validation. If someone has a blank form and presses submit, you'll send a blank email. So one thing you could add is some error checking to make sure the form is actually filled out before sending the email.

That PHP code is only going to work for the first form you posted though. The other forms have different sets of fields that the PHP is not checking for, or the PHP is checking for fields that are not in the form. Like was already pointed out, your third form has 2 fields with the same name ("name"), so only one of those is going to get submitted, and in your first form you have a radio button with the wrong name, it's using the name from a previous radio button group.
Was This Post Helpful? 0
  • +
  • -

#15 chris98   User is offline

  • D.I.C Lover

Reputation: 42
  • View blog
  • Posts: 1,129
  • Joined: 06-July 13

Re: Need help with coding report table! not able to send to email.

Posted 17 September 2014 - 10:18 AM

Quote

Poor coding practices early on can come back to bite you later.


They really do. I've spent the last year re-doing the last two years' worth of work on my site. It's much easier to learn correctly from the start. However, your code is extremely susceptible to email Injection:

  • No form validation. This is crucial. At the very least, use isset and something like htmlspecialchars, htmlentities or strip_tags.
  • $name = $_POST['name']; is pointless; they both contain the same value so you're achieving nothing - in fact, it's a waste of the server's time and is slowing your script down for no reason. Try using isset() instead.
  • mail() is insecure, you should use something like php mailer instead.

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2