PDA

View Full Version : Form help



Johnnikins
06-08-2008, 10:12 PM
Right, i have an email form, but the thing i am wanting to do with this email form, is to make it output in a table, because i will be using it for an invoice sort of system, so i am wanting to have a form for staff to submit, put all the information in, the email that they are wanting to send it to and then it sends it in a nice neat table to the recipient, any way of doing this

Thanks for all your help :]

Johnnikins
07-08-2008, 04:08 PM
<?php
if (isset($_REQUEST['Submit'])) {
# Feudel.co.uk Advertising Manager
$sql = "INSERT INTO $db_table(RefNum,Site,Contact,AddressLine1,Address Line2,TownCounty,PostCode,TelNo,InvoiceEmail,PayMe thod,StartDate,EndDate,bannerurl) values ('".mysql_real_escape_string(stripslashes($_REQUEST['RefNum']))."','".mysql_real_escape_string(stripslashes($_REQUEST['Site']))."','".mysql_real_escape_string(stripslashes($_REQUEST['Contact']))."','".mysql_real_escape_string(($_REQUEST['bannerurl']))."','".mysql_real_escape_string(($_REQUEST['TelNo']))."','".mysql_real_escape_string(($_REQUEST['InvoiceEmail']))."','".mysql_real_escape_string(($_REQUEST['PayMethod']))."','".mysql_real_escape_string(($_REQUEST['StartDate']))."','".mysql_real_escape_string(($_REQUEST['EndDate']))."','".mysql_real_escape_string(($_REQUEST['AddressLine1']))."','".mysql_real_escape_string(($_REQUEST['AddressLine2']))."','".mysql_real_escape_string(($_REQUEST['TownCounty']))."','".mysql_real_escape_string(($_REQUEST['PostCode']))."')";
if($result = mysql_query($sql ,$db)) {
echo '<div class="ocontentsection">
<div class="contenttext"><table class="gltable" cellpadding="0" cellspacing="0"><center>Thank you<br>Your information has been entered.<br><img src="http://www.feudel.co.uk/arcade/plugins/site/themes/GreyJohnsSkin/header/header_r1_c1.gif"><br><br><a href="http://www.feudel.co.uk/arcade/ads">Return</a>';
} else {
echo "ERROR: ".mysql_error();
}
} else {
?><div class="ocontentsection">
<div class="contenttext"><table class="gltable" cellpadding="0" cellspacing="0"><center>
If you have accepted an advertisement, Please enter information here, a reference number will then be generated and all staff will use this number when contacting the buyer of advertisements!</center>
<form method="post" action="">
<center>
<input type="hidden" name="RefNum" value="<?php $random = rand(000000000,999999999); echo $random; ?>">
<br>
<b>Site URL:</b> <br>
<input type="text" name="Site">
<br>
<b>Contact:</b><br>
<input type="text" name="Contact">
<br>
<b>Company Address:</b> <br>
<input type="text" name="AddressLine1">
<br><input type="text" name="AddressLine2">
<br><input type="text" name="TownCounty">
<br><input type="text" name="PostCode">
<br>
<b>Company Telephone Number:</b> <br>
<input type="text" name="TelNo">
<br>
<b>Invoice email address (Leave blank if the same as contact email address):</b> <br>
<input type="text" name="InvoiceEmail">
<br>
<b>Pay Method:</b> <br>
<input type="text" name="PayMethod">
<br>
<b>Start Date:</b> <br>
<input type="text" name="StartDate">
<br>
<b>End Date:</b> <br>
<input type="text" name="EndDate">
<br>
<b>Banner URL:</b><br>
<input type="text" name="bannerurl">
<br><br>
<input type="submit" name="Submit" value="Submit">
</center></form>
<?php
}
?>Okay i decided to give up on that one so i did this, i have my form, but when i submit it it sorta jiggles all of the results around into the wrong fields, BTW on their i haven't included my database connect but i do have one :]

Agnostic Bear
08-08-2008, 02:21 PM
<?php
if (isset($_REQUEST['Submit'])) {
# Feudel.co.uk Advertising Manager
$sql = "INSERT INTO $db_table(RefNum,Site,Contact,AddressLine1,Address Line2,TownCounty,PostCode,TelNo,InvoiceEmail,PayMe thod,StartDate,EndDate,bannerurl) values ('".mysql_real_escape_string(stripslashes($_REQUEST['RefNum']))."','".mysql_real_escape_string(stripslashes($_REQUEST['Site']))."','".mysql_real_escape_string(stripslashes($_REQUEST['Contact']))."','".mysql_real_escape_string(($_REQUEST['bannerurl']))."','".mysql_real_escape_string(($_REQUEST['TelNo']))."','".mysql_real_escape_string(($_REQUEST['InvoiceEmail']))."','".mysql_real_escape_string(($_REQUEST['PayMethod']))."','".mysql_real_escape_string(($_REQUEST['StartDate']))."','".mysql_real_escape_string(($_REQUEST['EndDate']))."','".mysql_real_escape_string(($_REQUEST['AddressLine1']))."','".mysql_real_escape_string(($_REQUEST['AddressLine2']))."','".mysql_real_escape_string(($_REQUEST['TownCounty']))."','".mysql_real_escape_string(($_REQUEST['PostCode']))."')";
if($result = mysql_query($sql ,$db)) {
echo '<div class="ocontentsection">
<div class="contenttext"><table class="gltable" cellpadding="0" cellspacing="0"><center>Thank you<br>Your information has been entered.<br><img src="http://www.feudel.co.uk/arcade/plugins/site/themes/GreyJohnsSkin/header/header_r1_c1.gif"><br><br><a href="http://www.feudel.co.uk/arcade/ads">Return</a>';
} else {
echo "ERROR: ".mysql_error();
}
} else {
?><div class="ocontentsection">
<div class="contenttext"><table class="gltable" cellpadding="0" cellspacing="0"><center>
If you have accepted an advertisement, Please enter information here, a reference number will then be generated and all staff will use this number when contacting the buyer of advertisements!</center>
<form method="post" action="">
<center>
<input type="hidden" name="RefNum" value="<?php $random = rand(000000000,999999999); echo $random; ?>">
<br>
<b>Site URL:</b> <br>
<input type="text" name="Site">
<br>
<b>Contact:</b><br>
<input type="text" name="Contact">
<br>
<b>Company Address:</b> <br>
<input type="text" name="AddressLine1">
<br><input type="text" name="AddressLine2">
<br><input type="text" name="TownCounty">
<br><input type="text" name="PostCode">
<br>
<b>Company Telephone Number:</b> <br>
<input type="text" name="TelNo">
<br>
<b>Invoice email address (Leave blank if the same as contact email address):</b> <br>
<input type="text" name="InvoiceEmail">
<br>
<b>Pay Method:</b> <br>
<input type="text" name="PayMethod">
<br>
<b>Start Date:</b> <br>
<input type="text" name="StartDate">
<br>
<b>End Date:</b> <br>
<input type="text" name="EndDate">
<br>
<b>Banner URL:</b><br>
<input type="text" name="bannerurl">
<br><br>
<input type="submit" name="Submit" value="Submit">
</center></form>
<?php
}
?>Okay i decided to give up on that one so i did this, i have my form, but when i submit it it sorta jiggles all of the results around into the wrong fields, BTW on their i haven't included my database connect but i do have one :]


That would be because the way you're inserting mysql doesn't match up, you're supposed to do:

INSERT INTO `blah` ( `1`, `2`, `3`, `4` ) VALUES ( '1', '2', '3', '4' )

what you're doing is:


INSERT INTO `blah` ( `1`, `2`, `3`, `4` ) VALUES ( '2', '4', '3', '1' )

may not be to scale


But yeah, just reorganise your fields, they're going in in the wrong order.

Johnnikins
09-08-2008, 02:06 AM
Thanks for the help :]

Want to hide these adverts? Register an account for free!