English 中文(简体)
• 如何从我的html形式上称为“加拿大”职能?
原标题:how to call a php function from my html form?
  • 时间:2012-04-30 19:22:21
  •  标签:
  • php
  • html
  • ajax

I have a template for a website, and I want to customize the message sender there. I saw this form to help out with the implementation of it.

The php file look as this:

<?php
echo  testing php ; 
$name = $_POST[ name ]; // contain name of person
$email = $_POST[ email ]; // Email address of sender 
$web = $_POST[ web ]; // Your website URL
$body = $_POST[ text ]; // Your message 
$receiver = "[email protected]" ; // hardcorde your email address here - This is the email address that all your feedbacks will be sent to 

$body = "Name:{$name}

Website :{$web}

Comments:{$body}";
$send = mail($receiver,  Contact Form Submission , $body, $email);
if ($send) {
    echo  true ; //if everything is ok,always return true , else ajax submission won t work
}
?>

<>>>>>

我已设法把“营地”的档案称为:

<form id="form" method="post" action="ajaxSubmit.php" > 
                <fieldset> 
                <label><input type="text" id="name" name="name" value="Name" onBlur="if(this.value==  ) this.value= Name " onFocus="if(this.value == Name  ) this.value=  "></label>
                  <label><input type="text" id="email" name="email" value="Email" onBlur="if(this.value==  ) this.value= Email " onFocus="if(this.value == Email  ) this.value=  "></label> 
                <label><input type="text" id="web" name="web" value="Phone" onBlur="if(this.value==  ) this.value= Phone " onFocus="if(this.value == Phone  ) this.value=  "></label>
                  <label><textarea id="text" name="text" onBlur="if(this.value==  ){this.value= Message }" onFocus="if(this.value== Message ){this.value=  }">Message</textarea></label> 
                <input type="reset" /> 
                <input type="submit" /> 
                </fieldset> 
                </form>

but when I run this I get teh following ERROR

Warning: mail() [function.mail]: SMTP server response: 550 The address is not valid. in C:wampwwwforSaledataTableajaxSubmit.php on line 17

but then I check the vallues of the variables, they are correct. what does that mean?

最佳回答

正如我在聊天中所说的那样,你应当首先提交表格,然后用javascript加以验证,然后尝试用jax提交表格。

如果你将表格重新贴上基本面,就会:

<form id="form" method="post" action="ajaxSubmit.php" >
    <fieldset>
        <input type="text" id="name" name="name" value="Name" 
                    onBlur="if(this.value==  ) this.value= Name " 
                    onFocus="if(this.value == Name  ) this.value=  " />
        <input type="text" id="email" name="email"  value="Email" 
                    onBlur="if(this.value==  ) this.value= Email "
                    onFocus="if(this.value == Email  ) this.value=  " />
        <input type="text" id="web" name="web"  value="Phone" 
                    onBlur="if(this.value==  ) this.value= Phone " 
                    onFocus="if(this.value == Phone  ) this.value=  " />
        <textarea id="text" name="text" value="Message"
                    onBlur="if(this.value==  ){this.value= Message }" 
                    onFocus="if(this.value== Message ) this.value=  }" />  
        <input type="reset" />
        <input type="submit" />
    </fieldset>  
</form>
问题回答

除非我没有咖啡在我的眼中玩弄trick,否则你没有具体说明这些投入的名称。 美元_POST不包含该要素的识别,而是名称和价值属性。

e.g:

<input type="text" id="name" value="Name" name="name" ...

edit: 辩论这一理论,尝试在贵PHP档案中计算出“POST”变量值

在投入领域添加名词:<代码>名称=“field_name”。 这可能会确定这一问题。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签