10 Replies - 522 Views - Last Post: 22 February 2013 - 04:45 PM Rate Topic: -----

#1 briana evigan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 22-February 13

problem in php script for sending email

Posted 22 February 2013 - 12:51 AM

the script was working
i know that it is a A small mistake but i cand find it :(/>
can you help me to find it ?


this is the script

<div class="msg-s">
		<?php
			$message_sent=false;
			if(isset($_POST['act']) && $_POST['act']=='send') {


				$headers =	'From: sales@rr.com' . "\r\n" .
							'Reply-To: sales@rr.com' . "\r\n";
				$nowdate= date('d/n/Y');
				$message = "
							[ $sub ]
							=====================================================
							===== Name : {$_POST['name']}
							===== Email : {$_POST['mail']}
							===== Mobile : {$_POST['phone']}
							=====================================================

							{$_POST['msg']}

							=====================================================
							[ $nowdate ]
							=====================================================
							{$_POST['mail']} From Site : {$_SERVER['HTTP_HOST']}
							";
				
				
				$message_sent=@mail('hhhhh@yahoo.com','Contact us form',$message,$headers);
			}
		?>
<div class="inputtt">
			<?php if($message_sent) :?>
				<div class="done">تم الارسال</div>
			<?php endIf?>
<form action="" method="post" name="formcheck" onsubmit="return formCheck(this);">
<div style="background-image:url('images/button.png');width:212px;height:40px;">
	<input type="text" style="border:thin white none;font-family:Tahoma;
    background:transparent;
    font-size:11px;color:#105872;position:absolute;width:150px;
    margin-left: 30px; margin-right: 6px; margin-top: 4px;
    text-align:right;" name="username"
    value="الاسم الثلاثى" onfocus="if(this.value == 'الاسم الثلاثى') {this.value = '';}"
     onblur="if (this.value == '') {this.value = 'الاسم الثلاثى';}">
</div>
<div style="background-image:url('images/button.png');width:212px;height:40px;">
	<input type="text" style="border:thin white none;font-family:Tahoma;
    background:transparent;
    font-size:11px;color:#105872;position:absolute;width:150px;
    margin-left: 30px; margin-right: 6px; margin-top: 4px;
    text-align:right;" name="username"
    value="البريد الإلكتروني" onfocus="if(this.value == 'البريد الإلكتروني') {this.value = '';}"
     onblur="if (this.value == '') {this.value = 'البريد الإلكتروني';}"></div>

<div style="background-image:url('images/button.png');width:212px;height:40px;">
	<input type="text" style="border:thin white none;font-family:Tahoma;
    background:transparent;
    font-size:11px;color:#105872;position:absolute;width:150px;
    margin-left: 30px; margin-right: 6px; margin-top: 4px;
    text-align:right;" name="username"
    value="اهمية الرسالة" onfocus="if(this.value == 'البريد الإلكتروني') {this.value = '';}"
     onblur="if (this.value == '') {this.value = 'البريد الإلكتروني';}"></div>



<div style="background-image:url('images/buttonmsg.png');width:212px;height:153px;">
	<input type="text" style="border:thin white none;font-family:Tahoma;
    background:transparent;
    height: 120px;
    font-size:11px;color:#105872;position:absolute;width:180px;
    margin-left: 30px; margin-right: 6px; margin-top: 4px;
    text-align:right;" name="username"
    value="محتوى الرسالة" onfocus="if(this.value == 'محتوى الرسالة') {this.value = '';}"
     onblur="if (this.value == '') {this.value = 'محتوى الرسالة';}"></div>


<input name="Submit1" type="submit" value=" " style="cursor: pointer;"/>
<input name="act" type="hidden" value="send" />
</div>

This post has been edited by Dormilich: 22 February 2013 - 02:37 AM
Reason for edit:: please use [code] [/code] tags when posting code


Is This A Good Question/Topic? 0
  • +

Replies To: problem in php script for sending email

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,239
  • Joined: 08-June 10

Re: problem in php script for sending email

Posted 22 February 2013 - 02:38 AM

if there is an error, you should get an error message when you enable error reporting and error display.
Was This Post Helpful? 0
  • +
  • -

#3 briana evigan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 22-February 13

Re: problem in php script for sending email

Posted 22 February 2013 - 04:08 AM

sorry,

the error is that i cant get the content of the message right

the message appears have apart of the code like this:

[ $sub ]
12
                            =====================================================
13
                            ===== Name : {$_POST['name']}
14
                            ===== Email : {$_POST['mail']}
15
                            ===== Mobile : {$_POST['phone']}
16
                            =====================================================
17
 
18
                            {$_POST['msg']}
19
 



.... i hope some one help me


Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,239
  • Joined: 08-June 10

Re: problem in php script for sending email

Posted 22 February 2013 - 04:21 AM

View Postbriana evigan, on 22 February 2013 - 12:08 PM, said:

the message appears have apart of the code like this: [...]

and what is wrong with that?
Was This Post Helpful? 0
  • +
  • -

#5 briana evigan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 22-February 13

Re: problem in php script for sending email

Posted 22 February 2013 - 04:28 AM

the wrong that if the user want to send a message as " i want any thing " as example
we receive it as

 [ $sub ]
02
12
03
                            =====================================================
04
13
05
                            ===== Name : {$_POST['name']}
06
14
07
                            ===== Email : {$_POST['mail']}
08
15
09
                            ===== Mobile : {$_POST['phone']}
10
16
11
                            =====================================================
12
17
13
  
14
18
15
                            {$_POST['msg']}
16
19


Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,239
  • Joined: 08-June 10

Re: problem in php script for sending email

Posted 22 February 2013 - 05:18 AM

I still do not understand the problem.
Was This Post Helpful? 0
  • +
  • -

#7 briana evigan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 22-February 13

Re: problem in php script for sending email

Posted 22 February 2013 - 09:57 AM

good
i'll give you an example

if i want to send a message in the browser
if i wrote in the content "hey,am Andy"
the message is sent as

===========
===== Name : {$_POST['name']}
===== Email : {$_POST['mail']}
===== Mobile : {$_POST['phone']}
=====================================================
{$_POST['msg']}



you can try it ?

the script has a small mistake as ( ' or " or } or ....)

do you understand me ?
Was This Post Helpful? 0
  • +
  • -

#8 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 440
  • View blog
  • Posts: 1,867
  • Joined: 30-April 10

Re: problem in php script for sending email

Posted 22 February 2013 - 11:23 AM

In stead of {$var} try this "text in message" . $var . "rest of message"

Let me know if this helps.

This post has been edited by laytonsdad: 22 February 2013 - 11:24 AM

Was This Post Helpful? 0
  • +
  • -

#9 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,520
  • Joined: 23-August 08

Re: problem in php script for sending email

Posted 22 February 2013 - 03:54 PM

I just don't think you can do multiline as you are doing.

Try using HEREDOC syntax:

<div class="msg-s">
		<?php
			$message_sent=false;
			if(isset($_POST['act']) && $_POST['act']=='send') {


				$headers =	'From: sales@rr.com' . "\r\n" .
							'Reply-To: sales@rr.com' . "\r\n";
				$nowdate= date('d/n/Y');
				$message =<<< EOM
[ $sub ]
=====================================================
===== Name : {$_POST['name']}
===== Email : {$_POST['mail']}
===== Mobile : {$_POST['phone']}
=====================================================

{$_POST['msg']}

=====================================================
[ $nowdate ]
=====================================================
{$_POST['mail']} From Site : {$_SERVER['HTTP_HOST']}
EOM;
				
				
				$message_sent=@mail('hhhhh@yahoo.com','Contact us form',$message,$headers);
			}
		?>
<div class="inputtt">
			<?php if($message_sent) :?>
				<div class="done">تم الارسال</div>
			<?php endIf?>
<form action="" method="post" name="formcheck" onsubmit="return formCheck(this);">
<div style="background-image:url('images/button.png');width:212px;height:40px;">
	<input type="text" style="border:thin white none;font-family:Tahoma;
    background:transparent;
    font-size:11px;color:#105872;position:absolute;width:150px;
    margin-left: 30px; margin-right: 6px; margin-top: 4px;
    text-align:right;" name="username"
    value="الاسم الثلاثى" onfocus="if(this.value == 'الاسم الثلاثى') {this.value = '';}"
     onblur="if (this.value == '') {this.value = 'الاسم الثلاثى';}">
</div>
<div style="background-image:url('images/button.png');width:212px;height:40px;">
	<input type="text" style="border:thin white none;font-family:Tahoma;
    background:transparent;
    font-size:11px;color:#105872;position:absolute;width:150px;
    margin-left: 30px; margin-right: 6px; margin-top: 4px;
    text-align:right;" name="username"
    value="البريد الإلكتروني" onfocus="if(this.value == 'البريد الإلكتروني') {this.value = '';}"
     onblur="if (this.value == '') {this.value = 'البريد الإلكتروني';}"></div>

<div style="background-image:url('images/button.png');width:212px;height:40px;">
	<input type="text" style="border:thin white none;font-family:Tahoma;
    background:transparent;
    font-size:11px;color:#105872;position:absolute;width:150px;
    margin-left: 30px; margin-right: 6px; margin-top: 4px;
    text-align:right;" name="username"
    value="اهمية الرسالة" onfocus="if(this.value == 'البريد الإلكتروني') {this.value = '';}"
     onblur="if (this.value == '') {this.value = 'البريد الإلكتروني';}"></div>



<div style="background-image:url('images/buttonmsg.png');width:212px;height:153px;">
	<input type="text" style="border:thin white none;font-family:Tahoma;
    background:transparent;
    height: 120px;
    font-size:11px;color:#105872;position:absolute;width:180px;
    margin-left: 30px; margin-right: 6px; margin-top: 4px;
    text-align:right;" name="username"
    value="محتوى الرسالة" onfocus="if(this.value == 'محتوى الرسالة') {this.value = '';}"
     onblur="if (this.value == '') {this.value = 'محتوى الرسالة';}"></div>


<input name="Submit1" type="submit" value=" " style="cursor: pointer;"/>
<input name="act" type="hidden" value="send" />
</div>



Was This Post Helpful? 0
  • +
  • -

#10 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: problem in php script for sending email

Posted 22 February 2013 - 04:43 PM

No, what he's doing should work fine. It's perfectly OK to creating multi-line strings in PHP like that (though it tends to get messy), and using {$var} is no different from doing " . $var . ". Neither of those will cause any problems.

What does seem odd in that code is that all the text inputs in the form are named "username". I'm guessing the solution to this problem is simply that these input elements need to be renamed to match the $_POST elements used in the PHP code.
Was This Post Helpful? 0
  • +
  • -

#11 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,520
  • Joined: 23-August 08

Re: problem in php script for sending email

Posted 22 February 2013 - 04:45 PM

Quote

It's perfectly OK to creating multi-line strings in PHP like that (though it tends to get messy)

OK, that's probably why I don't do it then :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1