form submit button action

Ask questions about iWebKit's code

form submit button action

Postby exit98studios on Sat 06 Feb 2010, 17:37

I've read through the other 2 threads on this, and I still don't quite understand how to get the submit button to do anything for me. i've got my entire form to look correct, but it doesn't do anything. I've tried adding the submit action for a mailto, but that just brings up the mail client, and doesn't grab any of the data inputed in my form. I know this has to be fairly simple, but I lack the knowledge to get it working. Any help is appreciated. The code for my form will be below, and the link to where it's live is http://homepage.mac.com/exit98/exit98studios/lyrica/form.html

-exit98Studios
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="index,follow" name="robots" />
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
<link href="pics/homescreen.png" rel="apple-touch-icon" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<title>Advancing Info
</title>
<meta content="iPod,iPhone,Webkit,iWebkit,Website,Create,mobile,Tutorial,free" name="keywords" />
<meta content="Try out all exclusive features iWebKit 4.0 has to offer and discover how far web developement can go. Create the ultimate WebApp!" name="description" />
</head>

<body>

<div id="topbar">
   <div id="title">
      Advancing Info</div>
      <div id="leftnav">
      <a href="index.html">Back</a></div>
   <div id="rightbutton">
      <a href="http://lyricaproduction.com/">Full Site</a></div>
</div>
   <div id="content">
      <ul class="pageitem">
         <li class="textbox">
           <p><div align="center">Please fill out the form below to submit your advancing information to the venue. If you have any questions, please contact our production manager: Ted Morgan Production@lyricaorlando.com</p>
           <p>Please read our Code Of Conduct as it has useful information for every band playing. It also covers topics such as parking, load in/out proceedures.</p>
          (Fields denoted with * are required)</div>
         </li>
      </ul>
      <span class="graytitle">Band Info</span>
      <ul class="pageitem">
         <li class="form"><span class="narrow"><span class="name">First Name</span><input type="text" />
         </span></li>
         <li class="form"><span class="narrow"><span class="name">Last Name</span><input type="text" />
         </span></li>
         <li class="form"><span class="narrow"><span class="name">Band Name</span><input type="text" />
         </span></li>
         <li class="form"><span class="narrow"><span class="name">Contact Phone</span><input type="text" />
         </span></li>
         <li class="form"><span class="narrow"><span class="name">E-Mail</span><input type="text" />
         </span></li>
      </ul>
      <ul class="pageitem">
         <li class="form"><select name="a">
         <option value="1"># of Band Members</option>
         <option value="2">1</option>
         <option value="3">2</option>
         <option value="4">3</option>
         <option value="5">4</option>
         <option value="6">5</option>
         <option value="7">6</option>
         <option value="8">7</option>
         <option value="9">8</option>
         </select><span class="arrow"></span></li></ul>
      <ul class="pageitem">
         <li class="form"><select name="b">
         <option value="1"># of Crew</option>
         <option value="2">1</option>
         <option value="3">2</option>
         <option value="4">3</option>
         <option value="5">4</option>
         </select><span class="arrow"></span></li></ul>
      <ul class="pageitem">
         <li class="form"><select name="c">
         <option value="1">Own FOH Engineer</option>
         <option value="2">Yes</option>
         <option value="3">No</option>
         </select><span class="arrow"></span></li></ul>
      <ul class="pageitem">
         <li class="form"><span class="narrow"><span class="name">Date of Event</span><input type="text" />
         </span></li>
      </ul>
      </ul>
         <li class="textbox"><textarea name="TextArea">Comments/Input List</textarea></li>
      </ul>
      
      <ul class="pageitem">
      <span class="graytitle">Agree to the Code of Conduct</span>
         <li class="form"><span class="choice"><span class="name">I Agree</span><input name="music" type="radio" value="other" /></span></li></ul>
      <ul class="pageitem">
         <li class="form">
         <input name="Submit input" type="submit" value="Submit" /></li>
         <li class="form">
         <input name="Reset input" type="reset" value="Reset" /></li>
         </ul>
<div id="footer">
   <a href="http://www.lyricaorlando.com/" class="noeffect style4"><strong>COPYRIGHT 2010 ALL RIGHTS RESERVED LYRICA ORLANDO WWW.LYRICAORLANDO.COM  WWW.LYRICAPRODUCTION.COM</strong></a></div>

</body>

</html>
exit98studios
Noob
Noob
 
Posts: 3
Joined: Tue 24 Mar 2009, 04:59

Re: form submit button action

Postby crmunro on Sun 07 Feb 2010, 04:28

you need to add the <form> tags around your entire form :) what do you want it to do? I will modify your code for you... email you, insert into database, etc?
wadelaube wrote:I have created a mobile menu system with iWebkit, which is working really well, even though I have no idea what I am doing.
User avatar
crmunro
Dude
Dude
 
Posts: 304
Joined: Wed 30 Sep 2009, 18:29
Location: Perth, Australia

Re: form submit button action

Postby exit98studios on Mon 08 Feb 2010, 16:40

Much appreciated on the help. All I need it to do is take all of the data imputed into the form and have it emailed to a set email address. I was told by someone else that I need to use PHP. Is that correct, or is there an alternative?

-exit98
exit98studios
Noob
Noob
 
Posts: 3
Joined: Tue 24 Mar 2009, 04:59

Re: form submit button action

Postby gdscei on Mon 08 Feb 2010, 19:13

exit98studios wrote:Much appreciated on the help. All I need it to do is take all of the data imputed into the form and have it emailed to a set email address. I was told by someone else that I need to use PHP. Is that correct, or is there an alternative?

-exit98


Your webserver probably has a help page on how to make a contact form, which will be send to your inside-e-mailadress. If you can't find it, contact them. You need some kind of sender (which is mostly written in PHP yes), but probably your webserver has already provided this for you. so get their code, edit yours with it, and you are good to go.
Proud to be a Die-Hart fan :D
Current project I am busy with: The BETTER TabBar
My latest creation: iDC
Don't forget to check out my Twitter, website and the iWebkitWiki.
User avatar
gdscei
Die-Hart fan
Die-Hart fan
 
Posts: 614
Joined: Sun 08 Nov 2009, 17:10
Location: The Netherlands

Re: form submit button action

Postby crmunro on Tue 09 Feb 2010, 12:28

hey! I have your form - - hopefully you can stick this into the appropriate places :)
Code: Select all
<form action="emailsend.php" method="post">
<ul class="pageitem">
         <li class="form"><span class="narrow"><span class="name">First Name</span><input name="first" type="text" />
         </span></li>
         <li class="form"><span class="narrow"><span class="name">Last Name</span><input name="last" type="text" />
         </span></li>
         <li class="form"><span class="narrow"><span class="name">Band Name</span><input name="band" type="text" />
         </span></li>
         <li class="form"><span class="narrow"><span class="name">Contact Phone</span><input name="phone" type="text" />
         </span></li>
         <li class="form"><span class="narrow"><span class="name">E-Mail</span><input name="email" type="text" />
         </span></li>
      </ul>
      <ul class="pageitem">
         <li class="form"><select name="members">
         <option value="1"># of Band Members</option>
         <option value="2">1</option>
         <option value="3">2</option>
         <option value="4">3</option>
         <option value="5">4</option>
         <option value="6">5</option>
         <option value="7">6</option>
         <option value="8">7</option>
         <option value="9">8</option>
         </select><span class="arrow"></span></li></ul>
      <ul class="pageitem">
         <li class="form"><select name="crew">
         <option value="1"># of Crew</option>
         <option value="2">1</option>
         <option value="3">2</option>
         <option value="4">3</option>
         <option value="5">4</option>
         </select><span class="arrow"></span></li></ul>
      <ul class="pageitem">
         <li class="form"><select name="foh">
         <option value="1">Own FOH Engineer</option>
         <option value="Yes">Yes</option>
         <option value="No">No</option>
         </select><span class="arrow"></span></li></ul>
      <ul class="pageitem">
         <li class="form"><span class="narrow"><span class="name">Date of Event</span><input name="date" type="text" />
         </span></li>
      </ul>
      </ul>
         <li class="textbox"><textarea name="comments">Comments/Input List</textarea></li>
      </ul>
      
      <ul class="pageitem">
      <span class="graytitle">Agree to the Code of Conduct</span>
         <li class="form"><span class="choice"><span class="name">I Agree</span><input name="agree" type="radio" value="Yes" /></span></li></ul>
      <ul class="pageitem">
         <li class="form">
         <input name="Submit input" type="submit" value="Submit" /></li>
         <li class="form">
         <input name="Reset input" type="reset" value="Reset" /></li></form>
         </ul></form>

I haven't included all your code, just the bits that matter so you could concentrate on them :D

below is emailsend.php which needs to be placed in the folder as the above form
Code: Select all
<?php
$to = "cameron.r.munro@gmail.com"; //the email you want it sent to
$subject = "New Request";  //subject of email
$email = $_REQUEST['email'] ; //the email user entered on previous page - leave this
$first = $_REQUEST['first'] ;
$last = $_REQUEST['last'] ;
$band = $_REQUEST['band'] ;
$phone = $_REQUEST['phone'] ;
$members = $_REQUEST['members'] ;
$crew = $_REQUEST['crew'] ;
$foh = $_REQUEST['foh'] ;
$date = $_REQUEST['date'] ;
$comments = $_REQUEST['comments'] ;
$agree = $_REQUEST['agree'] ;
$message = "name: $first $last <br />band: $band <br />phone: $phone <br />number of members: $members <br />number of crew: $crew <br />Own FOH: $foh <br />date: $date <br />comments: $comments <br />agree: $agree";  //message
$headers = "From: $email"; //header that states the email address of user- leave this
$sent = mail($to, $subject, $message, $headers) ; //send the whole thing and report to code below

if($sent)
{print "Your mail was sent successfully<br /><br />";
echo $message; }
else
{print "We encountered an error sending your mail<br /><br />";
echo $message;
}
?>

you can format emailsend.php for iwebkit, I unfortunately didn't have time :|

If you have any problems, let me know :) @crmunro on twitter will get you the fastest response ;)
wadelaube wrote:I have created a mobile menu system with iWebkit, which is working really well, even though I have no idea what I am doing.
User avatar
crmunro
Dude
Dude
 
Posts: 304
Joined: Wed 30 Sep 2009, 18:29
Location: Perth, Australia

Re: form submit button action

Postby cinefillu on Thu 18 Feb 2010, 12:19

hello...
can you format this emailsend.php for iwebkit pleaseeeee?
i am really stuck on how to do this;
all i want is for it to work, sending the email with all the information submitted, keeping the same template cause i am gonna use it on the ipod touch; thanks a lot for the help
cinefillu
Noob
Noob
 
Posts: 6
Joined: Tue 16 Feb 2010, 16:28

Re: form submit button action

Postby crmunro on Mon 22 Feb 2010, 12:31

Sure, if you give me... a while ;) how soon do you need it?
wadelaube wrote:I have created a mobile menu system with iWebkit, which is working really well, even though I have no idea what I am doing.
User avatar
crmunro
Dude
Dude
 
Posts: 304
Joined: Wed 30 Sep 2009, 18:29
Location: Perth, Australia

Re: form submit button action

Postby cinefillu on Mon 22 Feb 2010, 18:12

it's not an emergency; i just want it to work...with the iwebkit template
thanks a million
cinefillu
Noob
Noob
 
Posts: 6
Joined: Tue 16 Feb 2010, 16:28

Re: form submit button action

Postby crmunro on Thu 25 Feb 2010, 15:50

oki doki :) sorry I took so long to reply, I recently got a mac and have been busy playing with my new toy :D

I'll add it to my list of things, probably be done by morning, if not tomorrow night :)
wadelaube wrote:I have created a mobile menu system with iWebkit, which is working really well, even though I have no idea what I am doing.
User avatar
crmunro
Dude
Dude
 
Posts: 304
Joined: Wed 30 Sep 2009, 18:29
Location: Perth, Australia

Re: form submit button action

Postby crmunro on Mon 01 Mar 2010, 17:07

aaaaand Done :D wasn't too hard, but sorry I took so long... my list got lost :|

okay, here it is:
Code: Select all
<?php
$to = "CHANGETHIS@YOURSERVER.COM"; //the email you want it sent to, make sure you change this
$subject = "New Request";  //subject of email
$email = $_REQUEST['email'] ; //the email user entered on previous page - leave this
$first = $_REQUEST['first'] ;
$last = $_REQUEST['last'] ;
$band = $_REQUEST['band'] ;
$phone = $_REQUEST['phone'] ;
$members = $_REQUEST['members'] ;
$crew = $_REQUEST['crew'] ;
$foh = $_REQUEST['foh'] ;
$date = $_REQUEST['date'] ;
$comments = $_REQUEST['comments'] ;
$agree = $_REQUEST['agree'] ;
$message = "name: $first $last <br />band: $band <br />phone: $phone <br />number of members: $members <br />number of crew: $crew <br />Own FOH: $foh <br />date: $date <br />comments: $comments <br />agree: $agree";  //message
$headers = "From: $email"; //header that states the email address of user- leave this
$sent = mail($to, $subject, $message, $headers) ; //send the whole thing and report to code below
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
<link href="pics/homescreen.png" rel="apple-touch-icon" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<title>Submission Status
</title>
</head>

<body>

<div id="topbar">
   <div id="title">
      if($sent)
{print "Success!";
}
else
{print "Uh oh...";
}</div>
      <div id="leftnav">
      <a href="index.html">Back</a></div>
   </div>
   <div id="content">
      <ul class="pageitem">
         <li class="textbox">
           <p><div align="center"><?php if($sent)
{print "Your mail was sent successfully";
}
else
{print "We encountered an error sending your mail";

}?></p>     
</div>
         </li>
      </ul>
     </div>
     </body>
</html>


basically all you had to do was take a basic iwebkit page, include the sendmail script and echo out the php responses in the appropriate places :)

let me know how it goes, I haven't tested the look of it so I might have screwed something up :S hopefully you can fix it though :)
wadelaube wrote:I have created a mobile menu system with iWebkit, which is working really well, even though I have no idea what I am doing.
User avatar
crmunro
Dude
Dude
 
Posts: 304
Joined: Wed 30 Sep 2009, 18:29
Location: Perth, Australia

Re: form submit button action

Postby theshka on Wed 03 Mar 2010, 07:17

Only a couple problems with the code above..
1) You need to add <? and ?> before and after the 'if/else' statement between the <div id="topbar"> tag for it to display properly.
2) On the confirmation page it will say 'We encountered an error sending your message" however, the message does go though?

Also, how would I extract a inputted number (or beginning of an email '1234567890') from the previous page textbox & append a '@blagblah.com' the user has selected form a select box, also on the previous page to create the email address '1234567890@blahblah.com' -- being the address I want my mail sent to? (Sorry if that was complicated to understand ha ha)

P.S. THANK YOU SO FREAKING MUCH FOR THIS CODE!!! YOU SAVED MY SANITY & PROJECTS LIFE! lol :D

-edit-
After cleaning up the spacing, and adding <?php instead of just <? to all the if statements in now shows the message has been successfully sent. Awesome!! :)
theshka
Noob
Noob
 
Posts: 7
Joined: Mon 22 Feb 2010, 06:56

Re: form submit button action

Postby crmunro on Thu 04 Mar 2010, 04:42

haha well spotted :)

you do indeed need <?php ?> around each, pardon me for missing it... i was in a hurry :S
and the if statement should say it failed if it did fail... if it didn't it would say success.

on the form page:
Code: Select all
<ul class="pageitem">
<li class="form"><span class="narrow"><span class="name">Email</span><input name="mail" type="text" />
         </span></li>
         <li class="form"><select name="at">
         <option value="@me.com">@me.com</option>
         <option value="@apple.com">@apple.com</option>
         <option value="@gmail.com">@gmail.com</option>
         <option value="@blahblah.com">@blahblah.com</option>
         <option value="@123.com">@123.com</option>
         </select><span class="arrow"></span></li></ul>

in the php add:
Code: Select all
$mail = $_REQUEST['mail'] $_REQUEST['at'];

and (make sure this comes after the two _REQUESTs above, to be on the safe side :)
Code: Select all
$to = $mail; //to send it to the selected email
$email = $mail; //to send it from the selected email


I really hope that works, all off the top of my head after 3 math tests D: i hate school :p

and you're welcome :D
wadelaube wrote:I have created a mobile menu system with iWebkit, which is working really well, even though I have no idea what I am doing.
User avatar
crmunro
Dude
Dude
 
Posts: 304
Joined: Wed 30 Sep 2009, 18:29
Location: Perth, Australia

Re: form submit button action

Postby theshka on Thu 04 Mar 2010, 05:37

I forgot to edit again after all that labor! ha ha I managed to figure out how to append it the way I wanted!! (I've been reading up on PHP as it's something I've never used before :p )

I started with your original code, GOOGLED many,many,many queries, modified what I needed & stripped off the irrelevant lines, then tested the hell out if and was left with this emailsend.php;

Code: Select all
<?php
$prefix = $_REQUEST['sendto'];
$suffix = $_REQUEST['carrier'];
$smsto = $prefix .= $suffix ;
$to = $smsto ;
$subject = "Sent using iSMS 306!";
$from = $_REQUEST ['sender'];
$message = "$message <$from>" ;
$sent = mail($to,$subject,$message);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="Javascript">
window.onresize = function() {
   if(window.innerWidth < 480) {
      // Portrait
   } else {
      // Landscape
     history.go(-1)
   }
}
</script>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<title>Submission Status</title>
</head>

<body>

<div id="topbar">
   <div id="title">
<?php
if ($sent) {
   print "Success!";
} else {
   print "Uh oh...";
}
?>
</div>
      <div id="leftnav">
      <A HREF="javascript:history.go(-1)">Back</a></div>
   </div>
   <div id="content">
      <ul class="pageitem">
         <li class="textbox">
           <p><div align="center">
<?php if($sent)
{
print "<br>";
print "<img src=\"images/sent.gif\">" ;
print "<br>";
print "Your SMS message has been sent to";
print "<br>" ;
print "<b>$to</b>" ;
print "<br><br>" ;
print "Thanks for using iSMS 306!";
print "<br><br>";
}
else
{
print "<br>";
print "<img src=\"images\error.gif\">" ;
print "<br>";
print "<b>We're sorry!!</b>";
print "<br>";
print "An error was encountered while";
print "<br>";
print " attempting to send your message.";
print "<br><br>" ;
print "Please try again!";
print "<br><br>";
}
?>
</p>     
</div></li></ul></div>
</body>
</html>




It works AMAZING-LY! :lol:
Last edited by theshka on Thu 04 Mar 2010, 05:55, edited 1 time in total.
theshka
Noob
Noob
 
Posts: 7
Joined: Mon 22 Feb 2010, 06:56

Re: form submit button action

Postby crmunro on Thu 04 Mar 2010, 05:52

Oh cool :) well done!
wadelaube wrote:I have created a mobile menu system with iWebkit, which is working really well, even though I have no idea what I am doing.
User avatar
crmunro
Dude
Dude
 
Posts: 304
Joined: Wed 30 Sep 2009, 18:29
Location: Perth, Australia

Re: form submit button action

Postby DaBomb1022 on Thu 04 Mar 2010, 06:12

If your new to php make sure you always use <?php to start not just <? Because some webhost will give you an error
DaBomb1022
Helpfull Member
Helpfull Member
 
Posts: 415
Joined: Fri 17 Jul 2009, 08:50


Return to Get iWebKit coding help

Who is online

Users browsing this forum: No registered users and 0 guests