PDA

View Full Version : Help with forms



ereed
06-15-2004, 09:54 PM
Need help with posting form data from my site. I would like to recieve input from this form posted directly. This is the code as it exists today, set up to mail to me.



<form action="mailto:info@winwithedwin.com" method="GET" enctype="multipart/form-data">
<input type="text" onBlur="if(this.value=='') this.value='Full Name...';" onFocus="if(this.value=='Full Name...') this.value='';" value="Full Name..." name="from" size="20">
<input type="text" onBlur="if(this.value=='') this.value='Phone Number...';" onFocus="if(this.value=='Phone Number...') this.value='';" value="Phone Number..." name="Phone" size="20">
<input type="text" onBlur="if(this.value=='') this.value='Email Address...';" onFocus="if(this.value=='Email Address...') this.value='';" value="Email Address..." name="email" size="20">
<textarea name="bodytext" cols="22" rows="3" id="textarea">Comments...</textarea>
<br>
<input type="submit" value="Submit" name="Submit">
<input type="reset" value="Reset" name="Submit2">
</form>

My ISP has a set of simple templates that allow me to create a CGI form page, such as this:






<tr><td width="14%"><b>Name:</b></td><td width="35%"><input type="text" name="name" size="30" style="width: 100%" value=""></td><td width="2%"> </td><td width="14%"><b>E-mail:</b></td><td width="35%"><input type="text" name="email" size="30" style="width: 100%" value="@"></td></tr><tr><td><b>Subject:</b></td><td colspan="4"><input type="text" name="subject" size="60" style="width: 100%" value=""></td></tr><tr><td valign="top"><b>Comments:</b></td><td colspan="4"><textarea cols="60" width="100%" rows="10" name="body" style="width: 100%"></textarea></td></tr><tr><td> </td><td colspan="4"><input class="button" type="submit" value="Save entry"></td></tr></table></td></tr><input type="hidden" name="no" value="-1"><input type="hidden" name="entrykey" value="-1"><input type="hidden" name="key" value="HKr05u1c"><input type="hidden" name="adminkey" value=""><tr><td><table width="100%" cellspacing="0" class="invert"><tr><td class="invert" width="20%"> </td><td class="invert" align="center" width="60%"><a class="invert" href="http://misellbyowner.com:80/tinc?key=i525D8U4&amp;amp;start=-1&amp;amp;epp=5&amp;amp;reverse=1">Regular View</a> | <a class="invert" href="http://www.winwithedwin.com">Home</a></td><td class="invert" align="right" width="20%"> </td></tr></table></td></tr></table></form></center></body></html>


The template created form page is here: http://misellbyowner.com/tinc?key=pNWUPNEz&amp;no=-1&amp;entrykey=-1&amp;reverse=1

My site (with the input for a form) is here www.winwithedwin.com

Any help on how to post the fields from my website to the form for me to manage?

Or how to create and edit forms?

awddesign
06-16-2004, 09:52 AM
Hi edd

I have not tested this yet but should work




change this
<form action="mail.php" method="post" enctype="multipart/form-data">


Add these files to the site.



<?php

//mail.php

////////////
//from
//Phone
//email
//bodytext
///////////

include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','from');
pt_register('POST','Phone');
pt_register('POST','email');
pt_register('POST','bodytext');

if($from=="" || $email=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));

$message="name: ".$from."

Name: ".$from."
Email Address: ".$email."
Comments : ".$bodytext."
";
$bodytext = stripslashes($bodytext);

mail("info@winwithedwin.com","Form Submitted at your website",$message,"From:info@winwithedwin.com");

header("Refresh: 0;url=index.php");

?>

<?php
}
?>


//////////////

this is the
global.inc.php
file

/////////////


<?php

function pt_register()
{
$num_args = func_num_args();
$vars = array();

if ($num_args >= 2) {
$method = strtoupper(func_get_arg(0));

if (($method != 'SESSION') &amp;&amp; ($method != 'GET') &amp;&amp; ($method != 'POST') &amp;&amp; ($method != 'SERVER') &amp;&amp; ($method != 'COOKIE') &amp;&amp; ($method != 'ENV')) {
die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
}

$varname = "HTTP_{$method}_VARS";
global ${$varname};

for ($i = 1; $i < $num_args; $i++) {
$parameter = func_get_arg($i);

if (isset(${$varname}[$parameter])) {
global $$parameter;
$$parameter = ${$varname}[$parameter];
}

}

} else {
die('You must specify at least two arguments');
}

}

?>


Al

ereed
06-29-2004, 03:21 PM
I've added it, buit now I get a blank page when I submit. It should be at the root directory? (The same level where index.php is? Or stored under the template subdirectory?

ereed
06-29-2004, 03:25 PM
It's sending me the email directly, but it leaves the user on the blank mail.php page, rather than leaving them at the index.php page. Anybody have hints on how to redirect them to homepage?

Fat Lizard
06-30-2004, 02:10 AM
print "<script> function redirect() { window.location.replace('$files[core_login]'); } setTimeout('redirect();', 2000); </script>";

ereed
06-30-2004, 09:18 AM
I wasn't able to get the print <script> to work, but I was able to add a tag like this after the <?php>

<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="2;URL=http://www.yoursite.com/index.php">
</HEAD>

It seems to work OK, does the refresh rate have to be set in integer values?

Fat Lizard
06-30-2004, 12:06 PM
Your refresh rate is an integer.

As for my previous post .. Ooops, I just cut 'n pasted from a file .. You'd use something like :

print "<script> function redirect() { window.location.replace('index.php'); } setTimeout('redirect();', 2000); </script>";

This is assuming that the file you want to redirect to is in the same directory, and, 2000 ~= 2 secs.