Forum » Izdelava spletišč » Pomoč pri kontakt formi
Pomoč pri kontakt formi
Dejan209 ::
Živjo,
imam eno težavo in sicer sem pobral en template in mi ne rata urediti contact forme.
v htmlju imam sledečo formo:
zraven imam še v BIN mapi mailhandler.php
in mailhandler.ashx
in zadeva ko dam na net mi nekako ne dela?! ve kdo, kje sem zajebal stvar ? oz. me usmeri dalje, kjer bi lahko dobil kakšno informacijo ?
hvala! :)
imam eno težavo in sicer sem pobral en template in mi ne rata urediti contact forme.
v htmlju imam sledečo formo:
<form id="contact-form">
<fieldset>
<label>
<input type="text" value="Name" onBlur="if(this.value=='') this.value='Name'" onFocus="if(this.value =='Name' ) this.value=''" />
</label>
<label>
<input type="text" value="Email" onBlur="if(this.value=='') this.value='Email'" onFocus="if(this.value =='Email' ) this.value=''" />
</label>
<label>
<input type="text" value="Phone" onBlur="if(this.value=='') this.value='Phone'" onFocus="if(this.value =='Phone' ) this.value=''" />
</label>
<textarea onBlur="if(this.value=='') this.value='Message'" onFocus="if(this.value =='Message' ) this.value=''">Message</textarea>
<div class="buttons-wrapper">
<a class="button" onClick="document.getElementById('contact-form').reset()">Clear</a>
<a class="button" onClick="document.getElementById('contact-form').submit()">Send</a>
</div>
</fieldset>
</form>zraven imam še v BIN mapi mailhandler.php
<?php
$owner_email = $_POST["owner_email"];
$headers = 'From:' . $_POST["email"];
$subject = 'A message from your site visitor ' . $_POST["name"];
$messageBody = "";
$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
if($_POST['state']!='nope'){
$messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['phone']!='nope'){
$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['fax']!='nope'){
$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
if($_POST["stripHTML"] == 'true'){
$messageBody = strip_tags($messageBody);
}
try{
if(!mail($owner_email, $subject, $messageBody, $headers)){
throw new Exception('mail failed');
}else{
echo 'mail sent';
}
}catch(Exception $e){
echo $e->getMessage() ."\n";
}
?>in mailhandler.ashx
<%@ WebHandler Language="C#" Class="Handler" Debug="true" %>
using System;
using System.Web;
using System.Net.Mail;
using System.Text.RegularExpressions;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
SmtpClient mailClient = new SmtpClient(context.Request.Form.Get("mail.google.com"));
string owner_email = context.Request.Form.Get("xxx@gmail.com");
string subject = "A message from your site visitor " + context.Request.Form.Get("name");
string email = context.Request.Form.Get("email");
string messageBody = "";
messageBody += "<p>Visitor: " + context.Request.Form.Get("name") + "</p>\n";
messageBody += "<br>\n";
messageBody += "<p>Email Address: " + context.Request.Form.Get("email") + "</p>\n";
messageBody += "<br>\n";
messageBody += "<p>Phone Number: " + context.Request.Form.Get("phone") + "</p>\n";
messageBody += "<br>\n";
messageBody += "<p>Message: " + context.Request.Form.Get("message") + "</p>\n";
MailMessage message = new MailMessage();
try{
message.From = new MailAddress(email.ToString());
}catch (FormatException e) {
context.Response.Write(e.Message);
}
message.To.Add(owner_email);
message.Subject = subject;
if(context.Request.Form.Get("stripHTML") == "true"){
message.IsBodyHtml = false;
messageBody = Regex.Replace(messageBody, "<.*?>", string.Empty);
}else{
message.IsBodyHtml = true;
}
message.Body = messageBody;
try{
mailClient.Send(message);
}catch (SmtpException e) {
context.Response.Write("mail failed");
}
context.Response.Write("mail sent");
}
public bool IsReusable {
get {
return false;
}
}
}in zadeva ko dam na net mi nekako ne dela?! ve kdo, kje sem zajebal stvar ? oz. me usmeri dalje, kjer bi lahko dobil kakšno informacijo ?
hvala! :)
dukedl ::
jz bi nahitr reku, da bi manjka action v form oznaki
Glej pri Submit Button
http://www.w3schools.com/html/html_form...
Glej pri Submit Button
http://www.w3schools.com/html/html_form...
lp dukedl
HardFu ::
ce hoces dobit spremenljivko $_POST["email"], potem rabis input tag, ko ma name="email" atribut, isto velja za ostala polja (name, fax, state ....)
http://codeable.io
bzp ::
A to si iz treh tutorialov svojo verzijo skupaj spravil? Ker IMHO je en file preveč, ostala dva pa nista pravilno "zvezana" skupaj.
Vzdevek ::
Kaj pa v mailhandler.ashx a ni tukaj potrebno vnesti svojega maila ali si to že storil?
string owner_email = context.Request.Form.Get("xxx@gmail.com"); Vredno ogleda ...
| Tema | Ogledi | Zadnje sporočilo | |
|---|---|---|---|
| Tema | Ogledi | Zadnje sporočilo | |
| » | Davčne blagajne (strani: 1 2 3 4 … 24 25 26 27 )Oddelek: Programiranje | 352447 (92450) | Macketina |
| » | Web services - Neveljavni karakterji v XMLOddelek: Programiranje | 4860 (3972) | boolsheat |
| » | Visual BasicOddelek: Programiranje | 3703 (2729) | cekr |
| » | Kontakt obrazecOddelek: Izdelava spletišč | 2231 (2076) | betmen |
| » | [ASP.NET] send mailOddelek: Programiranje | 1406 (1343) | Microsoft |