I'm pretty new to WordPress and web development. I've been working on converting an older website to WordPress for a person I do business with. I've got almost everything done, but I'm having trouble getting his contact form to work properly. I've created a custom template for the page, but am not sure how to get the page for when the email is sent to work. My template code looks like this
<?php
/*Template Name: Contact*/
?>
<?php
get_header();
?>
<?php $nav = get_field ('navigation_links'); ?>
<body bgcolor="#ffffff" onload="MM_preloadImages('<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c1_s2.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c1_s4.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c1_s3.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c3_s2.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c3_s4.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c3_s3.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c5_s2.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c5_s4.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c5_s3.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c7_s2.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c7_s4.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c7_s3.png');">
<div class = "container" style = "background-image:url(<?php bloginfo('template_directory')?>/images/Generic_Background.jpg);">
<div id="header" style="position:relative;">
<div id="FWTableContainer1270816879">
<table style="display: inline-table;" border="0" cellpadding="0" cellspacing="0" width="960">
<!-- fwtable fwsrc="masthead.png" fwpage="Page 1" fwbase="masthead.png" fwstyle="Dreamweaver" fwdocid = "1270816879" fwnested="0" -->
<tr>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="179" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="55" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="179" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="89" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="179" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="68" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="199" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="12" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="8"><img name="masthead_r1_c1_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r1_c1_s1.png" width="960" height="193" border="0" id="masthead_r1_c1_s1" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="1" height="193" border="0" alt="" /></td>
</tr>
<tr>
<td><img name="masthead_r2_c1_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c1_s1.png" width="179" height="43" border="0" id="masthead_r2_c1_s1" alt="" /></td>
<td><img name="masthead_r2_c2_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c2_s1.png" width="55" height="43" border="0" id="masthead_r2_c2_s1" alt="" /></td>
<td><img name="masthead_r2_c3_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c3_s1.png" width="179" height="43" border="0" id="masthead_r2_c3_s1" alt="" /></td>
<td><img name="masthead_r2_c4_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c4_s1.png" width="89" height="43" border="0" id="masthead_r2_c4_s1" alt="" /></td>
<td><img name="masthead_r2_c5_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c5_s1.png" width="179" height="43" border="0" id="masthead_r2_c5_s1" alt="" /></td>
<td><img name="masthead_r2_c6_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c6_s1.png" width="68" height="43" border="0" id="masthead_r2_c6_s1" alt="" /></td>
<td><img name="masthead_r2_c7_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c7_s1.png" width="199" height="43" border="0" id="masthead_r2_c7_s1" alt="" /></td>
<td><img name="masthead_r2_c8_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c8_s1.png" width="12" height="43" border="0" id="masthead_r2_c8_s1" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="1" height="43" border="0" alt="" /></td>
</tr>
</table>
<div id="MMMenuContainer1120175513_0">
<div id="MMMenu1120175513_0" onmouseout="MM_menuStartTimeout(1000);" onmouseover="MM_menuResetTimeout();"> Pistols & Knives Rifles & Shotguns Collectibles & Antiques </div>
</div>
</div>
</div>
<div class="content" style="position:relative;">
<!-- InstanceBeginEditable name="maincontent" --><div id="centertable"><center><table width="70%" border="0" cellpadding="2" cellspacing="0" style="background-color:#fcb076;">
<tr>
<td align="center"><h2 style="margin-top:4px;">Contact Information</h2> <h5>Phone: 574.295.6440<br />
Monday – Friday 9:00 am – 5:00 pm Eastern Standard Time</h5>
<h5>Saturdays 9:00 am - noon<br />
Fax: 574.522.1600 (Anytime)</h5></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><h5>Mailing Address:<br />
22382 State Road 120 Elkhart, IN 46516</h5></td>
<td align="center"><h5>Physical Address:<br />
22382 State Road 120 Elkhart, IN 46516</h5></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><h5>E-mail - paul.stybert#gmail.com</h5></td>
</tr>
<tr>
<td><h5>If you have questions, you can reach us by phone, fax, regular mail, or use the email form below. This form will be sent to a customer service representative, who will be in contact with you soon. Thank you for your interest in Doug's Guns.</h5></td>
</tr>
<tr style="background-color:#005d90;color:#fff;">
<td align="center" style="border:1px solid #000;"><h3>Online Information Request Form</h3></td>
</tr>
<tr >
<td align="center" style="border:1px solid #000;background-color:#d3a06f;"><form action="<?php bloginfo('template_directory')?>/template-emailproc.php" method="post" id="mailform" name="mailform">
<input type="hidden" value="yxstreme" name="name" />
<table width="80%" border="0" cellspacing="0" cellpadding="2" class="formtable" style="margin-top:0px;">
<tr>
<td align="right" valign="top">*Name</td>
<td align="left" valign="top"><span id="sprytextfield1">
<input type="text" name="txtName" id="txtName" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></td>
</tr>
<tr>
<td align="right" valign="top">*Email</td>
<td align="left" valign="top"><span id="sprytextfield2">
<input type="text" name="txtEmail" id="txtEmail" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td align="right" valign="top">Company</td>
<td align="left" valign="top"><label for="txtCompany"></label>
<input type="text" name="txtCompany" id="txtCompany" /></td>
</tr>
<tr>
<td align="right" valign="top">Address</td>
<td align="left" valign="top"><label for="txtAddress"></label>
<input type="text" name="txtAddress" id="txtAddress" /></td>
</tr>
<tr>
<td align="right" valign="top">City</td>
<td align="left" valign="top"><label for="txtCity"></label>
<input type="text" name="txtCity" id="txtCity" /></td>
</tr>
<tr>
<td align="right" valign="top">State</td>
<td align="left" valign="top"><label for="txtState"></label>
<input type="text" name="txtState" id="txtState" /></td>
</tr>
<tr>
<td align="right" valign="top">Postal Code</td>
<td align="left" valign="top"><label for="txtPostalCode"></label>
<input type="text" name="txtPostalCode" id="txtPostalCode" /></td>
</tr>
<tr>
<td align="right" valign="top">Phone</td>
<td align="left" valign="top"><label for="txtPhone"></label>
<input type="text" name="txtPhone" id="txtPhone" /></td>
</tr>
<tr>
<td align="right" valign="top">Interested In:</td>
<td align="left" valign="top"><select name="ddInterest" class="contactformoption" id="ddInterest">
<option value="null" selected="selected">Please Choose One</option>
<option value="Buying One Of Our Products">Buying One Of Our Products</option>
<option value="Pistols">Pistols</option>
<option value="Rifles or Shotguns">Rifles or Shotguns</option>
<option value="Collectibles">Collectibles</option>
<option value="Other">Other</option></select></td>
</tr>
<tr>
<td align="right" valign="top">How did you find our website?</td>
<td align="left" valign="top">
<input type="text" name="txtHowFind" id="txtHowFind" /></td>
</tr>
<tr>
<td align="right" valign="top">Comments/Questions</td>
<td align="left" valign="top"><label for="txtComment"></label>
<textarea name="txtComments" id="txtComment" cols="60" rows="5"></textarea></td>
</tr>
<tr>
<td align="right" valign="top"> </td>
<td align="left" valign="top"><input type="submit" name="btnSubmit" id="btnSubmit" value="Send" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table></center>
</div>
<!-- InstanceEndEditable -->
<!-- end .content --></div>
<!-- end .container --></div>
</body>
<?php wp_footer();?>
<!-- InstanceEnd --></html>
I know it has something to do with the post method and where the email is being sent I changed the link to a page I've created with a custom template. The code that is different in that template is
<div class="content" id="maincontent"><!-- InstanceBeginEditable name="MainContent" -->
<%
on error resume next
xname=request.form("txtName")
xemail=request.form("txtEmail")
xcompany=request.form("txtCompany")
xaddress=request.form("txtAddress")
xcity=request.form("txtCity")
xstate=request.form("txtState")
xpostalcode=request.form("txtPostalCode")
xphone=request.form("txtPhone")
xinterest=request.form("ddInterest")
xhowfind=request.form("txtHowFind")
xcomments=request.form("txtComments")
If Request.form("name") = "yxstreme" Then
psFrom="no-reply#plugguardstore.com"
psSubject="Contact from Doug's Guns Website"
' message body
psbody = "<html><head><title>E-mail sent from the Doug's Guns website</title></head>"
psBody="<body><h5>The following e-mail was sent from the Doug's Guns website :</h5>"
psBody=psBody & "<hr />"
psBody=psBody & "<p>Name: " & xname & "</p>"
psBody=psBody & "<p>Email" & xemail & "<br />Company: " & xcompany & "<br />Address: " & xaddress & "<br />"
psBody=psBody & "City: " & xcity & "<br />State: " & xstate & "<br />Postal Code: " & xpostalcode & "<br />"
psBody=psBody & "Phone: " & xphone & "<br />"
psBody=psBody & "Interested In: " & xinterest & "<br /><br />"
psBody=psBody & "Discovered Website How: " & xhowfind & "<br /><br />"
psBody=psBody & "Comment/question:<br />" & xcomments & "<br /><br />"
psBody=psBody & "</body></html>"
strErr = ""
bSuccess = False
'On Error Resume Next
'sendCDOHTMLEmail "paul.stybert#gmail.com",psFrom,psSubject,psBody
sendCDOHTMLEmail "paul.stybert#gmail.com.com",psFrom,psSubject,psBody
'sendCDONTSHTMLEmail "paul.stybert#gmail.com",psFrom,psSubject,psBody,1
If Err <> 0 Then ' error occurred
strErr = Err.Description
response.write "<center><h3>There was a problem sending your message.</h3></center>"
'response.write Err.Description
else
bSuccess = True
response.write "<center><h3>Thanks! Someone will be in touch with you shortly.</h3></center>"
End If
End If
%>
<!-- InstanceEndEditable --><!-- end .content --></div>
I'm lost on what I need to do to make this work. Any help would be appreciated. For your information the website was originally created with DreamWeaver and I've been moving the html code over and adding php for WordPress into it.
As I understand you want to ditch the asp processing for a Wordpress solution?
Apart from the good suggestion that #biesior gave about a form plugin (ninja forms, gravity forms), this would in your case be done by leaving the action part of the form empty (the form will then post to the same page) and handling the post variables and mailing in your template, just above the get_header(). You would also need to put conditions around the form content like this: if (!isset($_POST["btnSubmit"]) { ... }, so that it doesn't show if the form has been posted.
Look into the wp_mail function. And put a nonce in that form and probably a (re)captcha.
But, forms are nasty and a lot of work, so look into one of the popular form plugins. You'll set this one up in no-time
Related
I am trying to add an option in the backend of an administration panel where admins can change the user type. Called: Change User Type
Before these were the options available: Add Notes about Driver and Change Email :
I modified the php and added the front end selector to Change user type in the admin panel:
But the problem is that it keeps pulling a box to enter data. I want a list with all user types to be listed in a drop down so I can select a user type and change and not add notes to it.
In the database I only have three types of users "user_group". They are listed under Ids 1, 2, and 3.
MY QUESTION IS:
How can I make a drop down list appear, once I select Change User Type after already having selected the user under the Select Driver options in the previous drop down?
My user type ids are listed under user_group
Below is the current code on the file, which is not very much:
function fn_ACTION_METHOD(sMethod){
if(sMethod=='notes'){
document.getElementById('comment_box').style.display='block';
document.getElementById('email_box').style.display='none';
document.getElementById('btnSUBMIT').value='ADD NOTES';
}else if(sMethod=='email'){
document.getElementById('comment_box').style.display='none';
document.getElementById('email_box').style.display='block';
document.getElementById('btnSUBMIT').value='CHANGE EMAIL';
}else if(sMethod=='user_group'){
document.getElementById('comment_box').style.display='none';
document.getElementById('email_box').style.display='block';
document.getElementById('btnSUBMIT').value='ChangeType';
}
}
function fn_LOAD_EMAIL(iDriverID){
$.get("ajax_data.php", {action: 'load-email', did: iDriverID}, function(data){
if (data=="ERROR"){
$('#Message').html("Error!!! in loading driver email");
}else{
$('#txtemail').val(data);
}
}, 'html');
}
</script>
</head>
<body style="margin: 0px;">
<div align="center">
<table border="0" cellspacing="0" cellpadding="0">
<!--start header -->
<? include('inc_header.php'); ?>
<!-- start side nav -->
<!-- actual page -->
<td>
<table border="0" cellspacing="0" cellpadding="0" width="980">
<tr valign="top" align="left">
<td width="15" height="16"><img src="../assets/images/autogen/clearpixel.gif" width="15" height="1" border="0" alt=""></td>
<td width="1"><img src="../assets/images/autogen/clearpixel.gif" width="1" height="1" border="0" alt=""></td>
<td width="949"><img src="../assets/images/autogen/clearpixel.gif" width="683" height="1" border="0" alt=""></td>
<td width="15"><img src="../assets/images/autogen/clearpixel.gif" width="1" height="1" border="0" alt=""></td>
</tr>
<tr valign="top" align="left">
<td height="40"></td>
<td colspan="2" width="949">
<table border="0" cellspacing="0" cellpadding="0" width="949" style="background-image: url('../assets/images/banner.png'); height: 40px;">
<tr align="left" valign="top">
<td width="100%">
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
<tr>
<td class="TextObject" align="center">
<h1 style="margin-bottom: 0px;">DRIVER NOTES & EMAIL CHANGE</h1>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top" align="left"><td colspan="4"> </td></tr>
<tr valign="top" align="left"><td colspan="4"> </td></tr>
<tr valign="top" align="left">
<td colspan="2"></td>
<td width="1050" class="TextObject" align="center">
<form name="frm1" action="driver_notes_email.php" method="post">
<input type="hidden" name="action" value="add_action" />
<table cellpadding="0" cellspacing="5" border="0" width="800" align="center" class="box">
<tr><td colspan="2" id="Message" width="100%"><?=$sMessage?></td></tr>
<tr>
<td class="label" width="200">Driver:</td>
<td width="800"><? fn_DISPLAY_USERS('drpdriver', 0, "200", "1", "--Select Driver--", "CONCAT(l_name, ' ', f_name) AS user_name", "l_name", $iGROUP_DRIVER.",".$iGROUP_COORDINATOR_STAFF, "fn_LOAD_EMAIL(this.value);");?></td>
</tr>
<tr>
<td class="label">Action:</td>
<td>
<div class="left"><input type="radio" id="opttype" name="optaction" value="ChangeType" onClick="fn_ACTION_METHOD('notes');"/></div>
<span class="label left">Change User Type</span>
<div class="left"><input type="radio" id="optnotes" name="optaction" value="Notes" onClick="fn_ACTION_METHOD('notes');"/></div>
<span class="label left">Add Notes about Driver</span>
<input type="radio" id="optreading" name="optaction" value="Change Email" onClick="fn_ACTION_METHOD('email');"/>
<span class="label">Change Email</span>
</td>
</tr>
<tr>
<td colspan="2">
<div id="email_box" style="display:none;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td class="label" width="200">Email:</td>
<td width="400"><input type="text" id="txtemail" name="txtemail" value="" maxlength="150" style="width:250px;" /></td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div id="comment_box" style="display:none; width:100%;">
<table cellpadding="0" cellspacing="5" border="0" width="100%">
<tr>
<td class="label" valign="top" width="200">Notes:</td>
<td width="400"><textarea name="txtcomments" id="txtcomments" cols="50" rows="10" style="width:250px;" ></textarea></td>
</tr>
</table>
</div>
</td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr><td></td><td><input type="button" name="btnSUBMIT" id="btnSUBMIT" value="ACTION" class="Button" onClick="valid_action(this.form);" style="width:150px;" /></td></tr>
</table>
</form>
</td>
<td></td>
</tr>
</table>
</td>
<!-- end actual page -->
<!-- footer -->
<? include('inc_footer.php'); ?>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
Look in your html code where the div id equals email_box. This box is already on the page but is hidden. In your javascript you added for the 'change user type' you correctly changed the action button but you are still just showing the email_box div by calling style display = block
You need to add a new div which is hidden by default with a select box in it, and only show it when the radio button is clicked. You will also need to add your php code in to actually update the user when the form is submitted.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Hi all here is my code below, when pressing the submit button i receive an error message "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE ID =' at line 7" Can not figure out what is wrong!? Please can you advise and help me see my mistake?
<?php
include 'connection.php';
if(!isset($_POST['submit'])) {
$q = "SELECT * FROM suppliers WHERE ID = $_GET[id]";
$results = mysql_query ($q);
$person = mysql_fetch_array($results);
}
if(isset($_POST['submit'])) {
$u = "UPDATE suppliers SET
`supplier_ABE_project_number`='$_POST[supplier_ABE_project_number]', `supplier_name`='$_POST[supplier_name]',
`supplier_capacity`='$_POST[supplier_capacity]', `supplier_contact`='$_POST[supplier_contact]',
`supplier_email`='$_POST[supplier_email]', `supplier_notes`='$_POST[supplier_notes]'
WHERE ID = $_POST[id]";
mysql_query ($u) or die (mysql_error());
}
?>
<style type="text/css"></style>
<link href="styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
background-color: #F5F6F8;
}
</style>
<table class="menu_hover" width="100%" border="0" cellspacing="0">
<tr>
<td height="104" valign="middle" bgcolor="#FFFFFF"><table width="1000" border="0" align="center" cellspacing="0">
<tr>
<td width="184"><img src="images/logo.jpg" alt="" width="95" height="90" /></td>
<td width="812" align="right"><table width="0" border="0" cellspacing="0" cellpadding="10">
<tr class="navi_menu">
<td width="38" align="center" nowrap="nowrap" class="menu_SECONDARY"><img src="images/project_btn.png" alt="" width="139" height="32" /></td>
<td width="77" align="center" nowrap="nowrap" class="menu_SECONDARY">Reports</td>
<td width="77" align="center" nowrap="nowrap" class="menu_SECONDARY">Dashboard</td>
<td width="56" align="center" nowrap="nowrap" class="menu_SECONDARY">Log Out</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="6" align="center" valign="bottom" bgcolor="#FFFFFF"><img src="images/header_line.png" alt="" width="1297" height="4" /></td>
</tr>
</table>
<table width="100" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<th height="200" scope="col"> </th>
</tr>
</table>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" />
<table width="1000" border="0" align="center" cellpadding="10" cellspacing="0" class="corners_white">
<tr>
<th width="950" valign="middle" bgcolor="#999999" class="corners" scope="col"><p class="titleWHITE">MODIFY CONTACT</p></th>
</tr>
<tr>
<th valign="middle" bgcolor="#FFFFFF" class="corners" scope="col"><table width="950" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<th width="77" height="39" align="left" valign="bottom" scope="col"><span class="text">PN</span></th>
<th width="278" align="left" valign="bottom" scope="col"><span class="text">Name</span></th>
<th width="144" align="left" valign="bottom" scope="col"><span class="text">Capacity</span></th>
<th width="193" align="left" valign="bottom" scope="col"><span class="text">Contact</span></th>
<th width="177" align="left" valign="bottom" scope="col"><span class="text">Email</span></th>
<th colspan="2" align="left" valign="bottom" scope="col"><span class="text">Notes</span></th>
</tr>
<tr>
<td align="left" valign="middle"><span class="text">
<input name="supplier_ABE_project_number" type="text" id="supplier_ABE_project_number" value="<?php echo $person['supplier_ABE_project_number']?>" size="10" />
</span></td>
<td align="left" valign="middle"><span class="text">
<input name="supplier_name" type="text" id="supplier_name" value="<?php echo $person['supplier_name']?>" size="10" />
</span></td>
<td align="left" valign="middle"><span class="text">
<input name="supplier_capacity" type="text" id="supplier_capacity" value="<?php echo $person['supplier_capacity']?>" size="10" />
</span></td>
<td align="left" valign="middle"><span class="text">
<input name="supplier_contact" type="text" id="supplier_contact" value="<?php echo $person['supplier_contact']?>" size="10" />
</span></td>
<td align="left" valign="middle"><span class="text">
<input name="supplier_email" type="text" id="supplier_email" value="<?php echo $person['supplier_email']?>" size="10" />
</span></td>
<td width="77" align="left" valign="middle"><span class="text">
<input name="supplier_notes" type="text" id="supplier_notes" value="<?php echo $person['supplier_notes']?>" size="10" />
</span></td>
<td align="left" valign="middle"> </td>
</tr>
</table> <p>
<input name="id" type="hidden" value="<?php echo $_GET['ID']; ?>" />
<input name="submit" type="submit" class="submit" value="Modify Contact" />
</form>
</th>
</tr>
</table>
You have to separate your fields with a comma in you update query:
UPDATE
suppliers
SET
`supplier_ABE_project_number`='$_POST[supplier_ABE_project_number]',
`supplier_name`='$_POST[supplier_name]',
`supplier_capacity`='$_POST[supplier_capacity]',
`supplier_contact`='$_POST[supplier_contact]',
`supplier_email`='$_POST[supplier_email]',
`supplier_notes`='$_POST[supplier_notes]'
WHERE ID = $_POST[id]
Additional tip: please escape you post and get params: http://php.net/manual/en/function.mysql-real-escape-string.php
Notice: Use of undefined constant login - assumed 'login' in C:\wamp\www\Online_exam\header.php on line 43
Notice: Use of undefined constant login - assumed 'login' in C:\wamp\www\Online_exam\header.php on line 47
Notice: Use of undefined constant login - assumed 'login' in C:\wamp\www\Online_exam\index.php on line 30
I am new to PHP and learning SESSION, and i am trying to explore on that and i am receiving the above errors. Everything looks correct for me. Please somebody help me.
Index.php
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Wel come to Online Exam</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="quiz.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("header.php");
include("database.php");
extract($_POST);
if(isset($submit))
{
$rs=mysql_query("select * from mst_user where login='$loginid' and pass='$pass'");
if(mysql_num_rows($rs)<1)
{
$found="N";
}
else
{
$_SESSION[login]=$loginid;
}
}
if (isset($_SESSION[login]))
{
echo "<h1 class='style8' align=center>Wel come to Online Exam</h1>";
echo '<table width="28%" border="0" align="center">
<tr>
<td width="7%" height="65" valign="bottom"><img src="image/HLPBUTT2.JPG" width="50" height="50" align="middle"></td>
<td width="93%" valign="bottom" bordercolor="#0000FF"> Subject for Quiz </td>
</tr>
<tr>
<td height="58" valign="bottom"><img src="image/DEGREE.JPG" width="43" height="43" align="absmiddle"></td>
<td valign="bottom"> Result </td>
</tr>
</table>';
exit;
}
?>
<table width="100%" border="0">
<tr>
<td width="70%" height="25"> </td>
<td width="1%" rowspan="2" bgcolor="#CC3300"><span class="style6"></span></td>
<td width="29%" bgcolor="#CC3333"><div align="center" class="style1">User Login </div></td>
</tr>
<tr>
<td height="296" valign="top"><div align="center">
<h1 class="style8">Wel come to Online Quiz</h1>
<span class="style5"><img src="image/paathshala.jpg" width="129" height="100"><span class="style7"><img src="image/HLPBUTT2.JPG" width="50" height="50"><img src="image/BOOKPG.JPG" width="43" height="43"></span> </span>
<param name="movie" value="english theams two brothers.dat">
<param name="quality" value="high">
<param name="movie" value="Drag to a file to choose it.">
<param name="quality" value="high">
<param name="BGCOLOR" value="#FFFFFF">
<p align="left" class="style5"> </p>
<blockquote>
<p align="left" class="style5"><span class="style7">Wel Come to Online
exam. This Site will provide the quiz for various subject of interest.
You need to login for the take the online exam.</span></p>
</blockquote>
</div></td>
<td valign="top"><form name="form1" method="post" action="">
<table width="200" border="0">
<tr>
<td><span class="style2">Login ID </span></td>
<td><input name="loginid" type="text" id="loginid2"></td>
</tr>
<tr>
<td><span class="style2">Password</span></td>
<td><input name="pass" type="password" id="pass2"></td>
</tr>
<tr>
<td colspan="2"><span class="errors">
<?php
if(isset($found))
{
echo "Invalid Username or Password";
}
?>
</span></td>
</tr>
<tr>
<td colspan=2 align=center class="errors">
<input name="submit" type="submit" id="submit" value="Login"> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#CC3300"><div align="center"><span class="style4">New User ? Signup Free</span></div></td>
</tr>
</table>
<div align="center">
<p class="style5"><img src="images/topleft.jpg" width="134" height="128"> </p>
</div>
</form></td>
</tr>
</table>
</body>
</html>
Header.php
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
-->
</style>
<table border="0" width="100%" cellspacing="0" cellpadding="0" background="image/topbkg.jpg">
<tr>
<td width="90%" valign="top">
<!--You can modify the text, color, size, number of loops and more on the flash header by editing the text file (fence.txt) included in the zip file.-->
<div align="left"><object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,2,0
width=500
height=68>
<param name=movie value=image/fence.swf>
<param name=quality value=high>
<param name=BGCOLOR value=#000000>
<param name=SCALE value=showall>
<param name=wmode value=transparent>
<embed src=image/fence.swf
quality=high
pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash
width=500
height=68
bgcolor=#000000
scale= showall>
</embed>
</object></div></td>
<td width="10%">
<img border="0" src="image/topright.jpg" width="203" height="68" align="right"></td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#000000" background="img/blackbar.jpg">
<tr>
<td width="100%" align="right"><img border="0" src="image/blackbar.jpg" width="89" height="15"></td>
</tr>
</Table>
<Table width="100%">
<tr>
<td>
<?php "Hi ".$_SESSION[login]; ?>
</td>
<td>
<?php
if(isset($_SESSION[login]))
{
echo "<div align=\"right\"><strong> Home |Signout</strong></div>";
}
else
{
echo " ";
}
?>
</tr>
</table>
session variable should wrap with ' '...
change your session variable like this...
$_SESSION['session_var_name'];
and in your case it should..
$_SESSION['login']
You have to give the session name inside quotes only. Use
$_SESSION['login'] or $_SESSION["login"]
Non-numeric array key constants should be enclosed in quotes, either single or double. Otherwise, php thinks you are referring to a constant name. And since it's undefined, it falls back to guessing you just forgot the quotes...
That's why it works. And that's why the issue appears as a Notice. But in order to do away with it, change $_SESSION[login] to $_SESSION['login'].
Replace $_SESSION[login] into $_SESSION['login'] in all occurance of your code
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Wel come to Online Exam</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="quiz.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("header.php");
include("database.php");
extract($_POST);
if(isset($submit))
{
$rs=mysql_query("select * from mst_user where login='$loginid' and pass='$pass'");
if(mysql_num_rows($rs)<1)
{
$found="N";
}
else
{
$_SESSION['login']=$loginid;
}
}
if (isset($_SESSION['login']))
{
echo "<h1 class='style8' align=center>Wel come to Online Exam</h1>";
echo '<table width="28%" border="0" align="center">
<tr>
<td width="7%" height="65" valign="bottom"><img src="image/HLPBUTT2.JPG" width="50" height="50" align="middle"></td>
<td width="93%" valign="bottom" bordercolor="#0000FF"> Subject for Quiz </td>
</tr>
<tr>
<td height="58" valign="bottom"><img src="image/DEGREE.JPG" width="43" height="43" align="absmiddle"></td>
<td valign="bottom"> Result </td>
</tr>
</table>';
// exit;
}
?>
<table width="100%" border="0">
<tr>
<td width="70%" height="25"> </td>
<td width="1%" rowspan="2" bgcolor="#CC3300"><span class="style6"></span></td>
<td width="29%" bgcolor="#CC3333"><div align="center" class="style1">User Login </div></td>
</tr>
<tr>
<td height="296" valign="top"><div align="center">
<h1 class="style8">Wel come to Online Quiz</h1>
<span class="style5"><img src="image/paathshala.jpg" width="129" height="100"><span class="style7"><img src="image/HLPBUTT2.JPG" width="50" height="50"><img src="image/BOOKPG.JPG" width="43" height="43"></span> </span>
<param name="movie" value="english theams two brothers.dat">
<param name="quality" value="high">
<param name="movie" value="Drag to a file to choose it.">
<param name="quality" value="high">
<param name="BGCOLOR" value="#FFFFFF">
<p align="left" class="style5"> </p>
<blockquote>
<p align="left" class="style5"><span class="style7">Wel Come to Online
exam. This Site will provide the quiz for various subject of interest.
You need to login for the take the online exam.</span></p>
</blockquote>
</div></td>
<td valign="top"><form name="form1" method="post" action="">
<table width="200" border="0">
<tr>
<td><span class="style2">Login ID </span></td>
<td><input name="loginid" type="text" id="loginid2"></td>
</tr>
<tr>
<td><span class="style2">Password</span></td>
<td><input name="pass" type="password" id="pass2"></td>
</tr>
<tr>
<td colspan="2"><span class="errors">
<?php
if(isset($found))
{
echo "Invalid Username or Password";
}
?>
</span></td>
</tr>
<tr>
<td colspan=2 align=center class="errors">
<input name="submit" type="submit" id="submit" value="Login"> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#CC3300"><div align="center"><span class="style4">New User ? Signup Free</span></div></td>
</tr>
</table>
<div align="center">
<p class="style5"><img src="images/topleft.jpg" width="134" height="128"> </p>
</div>
</form></td>
</tr>
</table>
</body>
</html>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
-->
</style>
<table border="0" width="100%" cellspacing="0" cellpadding="0" background="image/topbkg.jpg">
<tr>
<td width="90%" valign="top">
<!--You can modify the text, color, size, number of loops and more on the flash header by editing the text file (fence.txt) included in the zip file.-->
<div align="left"><object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,2,0
width=500
height=68>
<param name=movie value=image/fence.swf>
<param name=quality value=high>
<param name=BGCOLOR value=#000000>
<param name=SCALE value=showall>
<param name=wmode value=transparent>
<embed src=image/fence.swf
quality=high
pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash
width=500
height=68
bgcolor=#000000
scale= showall>
</embed>
</object></div></td>
<td width="10%">
<img border="0" src="image/topright.jpg" width="203" height="68" align="right"></td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#000000" background="img/blackbar.jpg">
<tr>
<td width="100%" align="right"><img border="0" src="image/blackbar.jpg" width="89" height="15"></td>
</tr>
</Table>
<Table width="100%">
<tr>
<td>
<?php
if(isset($_SESSION['login']))
{
print "Hi ".$_SESSION['login'];
}
?>
</td>
<td>
<?php
if(isset($_SESSION['login']))
{
echo "<div align=\"right\"><strong> Home |Signout</strong></div>";
}
else
{
echo " ";
}
?>
</tr>
</table>
Below is a contact us script in php, when I click submit at www.mydomain.com.au/contact.html it looks as though it works because I end up at ww.mydomain.com.au/thanks.html.
However the specified email account is not receiving contact emails.
Here is the code for the contact us script found at includes/contact_mail.php
<?php
if(isset($_POST['enter']) && $_POST['enter']==1)
{
$_SESSION['email']=$_POST['email'];
$to="name#domains.com";
$subject='Contact Us Details';
$message="<style>
.textstyle{
font-family:Tahoma;
font-size:11px;
color:#156E00;
text-align:left;
margin-left:10px;
text-decoration:none;
}
</style>";
$message.="<table width=400 border=0>
<tr><td class=textstyle>First Name: </td> <td class=textstyle>".$_POST['fname']."</td></tr>
<tr><td class=textstyle>Last Name: </td> <td class=textstyle>".$_POST['lname']."</td></tr>
<tr><td class=textstyle>E-mail: </td> <td class=textstyle>".$_POST['email']."</td></tr>
<tr><td class=textstyle>Phone Number: </td> <td class=textstyle>".$_POST['tel']."</td></tr>
<tr><td class=textstyle>Comments: </td> <td class=textstyle>".$_POST['que']."</td></tr>
</table>";
$mail_from = "From:".$_POST['email'];
$mail_from .="\r\nContent-type: text/html";
#mail($to,$subject,$message,$mail_from);
header("location: ../thankyou.html");
exit();
}
?>
Here is the code at ww.mydomain.com.au/contact.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="GENERATOR" content="Macromedia Dreamweaver CS3" />
<meta name="author" content="Relyon security" />
<meta name="keywords" content="Camera Surveillance,Spy Cameras,Remote Viewing,Audio recording,Relyon security" />
<meta name="description" content="" />
<meta http-equiv="EXPIRES" content="-1" />
<title>Relyon Security: About Relyon Security</title>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
<script language="JavaScript" type="text/javascript">
function fullcheck()
{
var str=document.contact.email.value;
//alert(str);
if (document.contact.fname.value=="")
{
alert ("Blank space not allowed. Please type your First Name.");
document.contact.fname.select();
return false;
}
if (document.contact.lname.value=="")
{
alert ("Blank space not allowed. Please type your Last Name.");
document.contact.lname.select();
return false;
}
if ((document.contact.email.value).indexOf(" ")>=0)
{
alert ("Blank space not allowed inside email!");
document.contact.email.select();
return false;
}
if (document.contact.email.value.indexOf("#",1) == -1)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.email.value.indexOf("#") == 0)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.email.value.indexOf(".",5) == -1)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.email.value.indexOf(".") == 0)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if ((document.contact.email.value.lastIndexOf(".")) -(document.contact.email.value.indexOf("#"))<4 )
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.tel.value=="")
{
alert ("Blank space not allowed. Please type your Telephone Number.");
document.contact.tel.select();
return false;
}
if (document.contact.que.value=="")
{
alert ("Blank space not allowed. Please enter your question or comment.");
document.contact.que.select();
return false;
}
}
//-->
</script>
</head>
<body>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" align="left" width="110" height="186"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
<td width="780" rowspan="2" align="center" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td height="161" valign="top"><img src="images/spacer.gif" alt="" /></td>
</tr>
<tr>
<td valign="top" align="left" class="btn">
<table width="780" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td width="10" valign="top"><img src="images/btn-left.jpg" alt="" width="10" height="49" /></td>
<td align="center" valign="middle">
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="154" align="center" valign="top">Home Page</td>
<td width="180" align="center" valign="top">Our Services</td>
<td width="244" align="center" valign="top">About relyon security</td>
<td width="182" align="center" valign="top"><span class="navg_contact_activated">Contact Us</span></td>
</tr>
</table>
</td>
<td width="10" valign="top" align="right"><img src="images/btn-right.jpg" alt="" width="10" height="49" /></td>
</tr>
<tr>
<td colspan="3" height="1" bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<tr>
<td width="10"><img src="images/left-bot.jpg" alt="" width="10" height="42" /></td>
<td class="shadow"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
<td><img src="images/rgh-bot.jpg" alt="" width="10" height="42" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top" align="left" width="110"><img src="images/spacer.gif" alt="" /></td>
</tr>
<tr>
<td valign="top" align="left" width="110" bgcolor="#FFFFFF" height="66"><img src="images/spacer.gif" alt="" /></td>
<td valign="top" align="left" width="110" bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="" /></td>
</tr>
</table>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center" class="white">
<tr>
<td valign="top" align="left"><table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" class="inner_text"><span class="head-blue">Contact Us</span><br /><br />
Email address: relyonsecurity#live.com.au
<br />
Phone: 0422 663 489<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center" class="blue">
<tr>
<td valign="top" align="left"><table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top">
<form name="contact" method="post" action="includes/contact_mail.php" onsubmit="return fullcheck()">
<table width="90%" border="0" cellpadding="0" cellspacing="3" >
<tr>
<td width="7%"> </td>
<td height="30" colspan="2" align="left" valign="middle"><span class="mandatory">*</span>Required fields</td>
</tr>
<tr>
<td> </td>
<td width="22%" class="form_text"><span class="mandatory">*</span>First Name :</td>
<td width="71%"><input name="fname" type="text" id="fname" size="35" class="inputbox"></td>
</tr>
<tr>
<td> </td>
<td width="22%" class="form_text"><span class="mandatory">*</span>Last Name :</td>
<td width="71%"><input name="lname" type="text" id="lname" size="35" class="inputbox"></td>
</tr>
<tr>
<td> </td>
<td class="form_text"><span class="mandatory">*</span>Email Address :</td>
<td><input name="email" type="text" class="inputbox" id="email" size="35"></td>
</tr>
<tr>
<td width="7%"> </td>
<td class="form_text"><span class="mandatory">*</span>Telephone Number:</td>
<td><input name="tel" type="text" class="inputbox" id="tel" size="35"></td>
</tr>
<tr>
<td> </td>
<td class="form_text"><span class="mandatory">*</span>Please enter your question or comment :</td>
<td><textarea name="que" cols="33" rows="8" id="que" class="inputbox"></textarea></td>
</tr>
<tr>
<td colspan="3" height="5" valign="top"><input name="enter" type="hidden" value="1" /></td>
</tr>
<tr>
<td> </td>
<td class="form_text"> </td>
<td><input type="submit" name="Submit" value="Submit" class="inputbox">
<input type="reset" name="Submit2" value="Reset" class="inputbox"></td>
</tr>
<tr>
<td colspan="3" height="30" valign="top"></td>
</tr>
</table>
</form>
<table width="780" border="0" cellspacing="0" cellpadding="0" align="center" class="footer" height="41">
<tr>
<td valign="top" width="12" height="8"><img src="images/foo-l-top.gif" alt="" width="12" height="8" /></td>
<td><img src="images/spacer.gif" alt="" /></td>
<td align="right" valign="top" width="9" height="8"><img src="images/foo-r-top.gif" alt="" width="9" height="8" /></td>
</tr>
<tr>
<td><img src="images/spacer.gif" alt="" /></td>
<td align="center" valign="middle">©2009 Relyon Security.com All Rights Reserved</td>
<td><img src="images/spacer.gif" alt="" /></td>
</tr>
<tr>
<td valign="bottom" height="8"><img src="images/foo-l-bot.gif" alt="" width="12" height="8" /></td>
<td><img src="images/spacer.gif" alt="" /></td>
<td valign="bottom"><img src="images/foo-r-bot.gif" alt="" width="9" height="8" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Second attempt at script?
<?php
error_reporting(E_ALL)
if(isset($_POST['enter']) && $_POST['enter']==1)
{
$_SESSION['email']=$_POST['email'];
$to="name#domains.com";
$subject='Contact Us Details';
$message="<style>
.textstyle{
font-family:Tahoma;
font-size:11px;
color:#156E00;
text-align:left;
margin-left:10px;
text-decoration:none;
}
</style>";
$message.="<table width=400 border=0>
<tr><td class=textstyle>First Name: </td> <td class=textstyle>".$_POST['fname']."</td></tr>
<tr><td class=textstyle>Last Name: </td> <td class=textstyle>".$_POST['lname']."</td></tr>
<tr><td class=textstyle>E-mail: </td> <td class=textstyle>".$_POST['email']."</td></tr>
<tr><td class=textstyle>Phone Number: </td> <td class=textstyle>".$_POST['tel']."</td></tr>
<tr><td class=textstyle>Comments: </td> <td class=textstyle>".$_POST['que']."</td></tr>
</table>";
$mail_from = "From:".$_POST['email'];
$mail_from .="\r\nContent-type: text/html";
mail($to,$subject,$message,$mail_from);
// header("location: ../thankyou.html");
exit();
}
?>
put error_reporting(E_ALL) at the top of the script, remove # from mail() call and comment string with header() and THEN look for errors
When i added <form> to my web page, all my javascript stopped working, and when i put the form at the begining of my table submit wont work, what i am doing wrong. below is my code after testing on other browser it works fine but on Firefox it doesn't
Update: After checking on firefox java error console it appears that Checking Function is defined
Update2: Solved my mistake was <script type="text/jscript"> is wrong thats why on firefox it wasn't working and on the rest it was, it must be <script type="text/javascript">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sabay Afrah.Inc | Contact Us</title>
<script src="js/clear.js" language="javascript" type="text/javascript"></script>
<script src="js/SpryValidationSelect.js" type="text/javascript"></script>
<script type="text/jscript">
function Checking(form){
if(empty(form.fname.value){
alert("do nothing");
}
}
</script>
<style type="text/css">
<!--
body {
background-color: #000;
}
body,td,th {
color: #FFF;
font-size: 14px;
}
.address {
font-family: "Comic Sans MS", cursive;
font-weight: bold;
}
-->
</style>
<link href="theme/style.css" rel="stylesheet" type="text/css" />
<link href="theme/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="enterdb.php" method="post">
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"> </td>
</tr>
<tr>
<td><table width="1006" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4"> </td>
<td width="93" align="right"> </td>
<td width="4"> </td>
<td width="374" ><img src="images/logo.png" width="230" height="114" /></td>
<td width="426" align="right" class="address">
10 GlenLake parkway<br />
Suite 130, mailbox # 76<br />
Atlanta, GA 30328<br />
Phone #: + 678-222-3442<br />
Fax #: +678-222-3401<br />
Office hours: M-F 8:30 a.m. to 5:00 p.m.<br />
</td>
<td width="99"> </td>
</tr>
<tr>
<td colspan="5"><table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td class="title"> </td>
</tr>
<tr>
<td width="84"><br /></td>
<td width="516" class="title">Contact Us</td>
</tr>
</table></td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table width="883" border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="table">
<td width="27" rowspan="10" bgcolor="#330099" class="textable"> </td>
<td colspan="2" bgcolor="#330099" class="textable"> </td>
<td width="29" rowspan="8" bgcolor="#330099" class="textable"> </td>
<td colspan="3" class="textable"> </td>
</tr>
<tr >
<td width="139" height="31" bgcolor="#330099" class="textable">First Name:</td> <td>
<input id="fname" name="fname" type="text" size="40" /> </td>
<td width="150" class="textable">Last Name:</td>
<td width="265" class="textable"><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td ><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td ><input id="lname" name="lname" type="text" size="40" /></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="32" class="textable"> </td>
</tr>
<tr>
<td height="30" class="textable">Subject:</td> <td>
<span id="spryselect1">
<label>
<select name="sub" id="sub">
<option> Choose a Subject</option>
<option> General Question</option>
<option> MemberShip Area</option>
<option> Others</option>
</select>
</label>
<span class="selectRequiredMsg">Please select a Subject.</span></span>
</td>
<td colspan="3" class="textable"> </td>
</tr>
<tr>
<td height="33" class="textable">Company Name:</td> <td> <input id="cname" name="cname" type="text" size="40" /></td>
<td class="textable">Company Address:</td>
<td class="textable"><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input id="cadd" name="cadd" type="text" size="40" onclick="" /></td>
</tr>
</table></td>
<td class="textable"> </td>
</tr>
<tr>
<td height="31" class="textable">Phone Number:</td> <td><input id="phonen" name="phonen" type="text" size="40" /> </td>
<td colspan="3" rowspan="4" class="textable"> </td>
</tr>
<tr>
<td height="31" class="textable">Fax Number:</td><td> <input id="faxn" name="faxn" type="text" size="40" /></td>
</tr>
<tr>
<td height="32" class="textable">Email Address:</td><td><input id="email" name="email" type="text" size="40" /></td>
</tr>
<tr>
<td colspan="2" class="textable"> </td>
</tr>
<tr>
<td valign="top" class="textable">Additional Information:</td>
<td colspan="5" class="textable"><table width="600" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="center">
<textarea id="add" name="add" cols="70" rows="10" /></textarea>
</td>
</tr>
<tr>
<td align="center" class="textable">
<input name="Submit" type="submit" value="Submit" onclick="Checking()"/>
</td>
<td align="center" class="textable">
<input type="reset" value="Clear" />
</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="6" class="textable"> </td>
</tr>
</table></td>
</tr>
</table>
</form>
<script type="text/javascript">
<!--
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
//-->
</script>
</body>
</html>
Your function wants to take in the form element and your submit button doesn't send anything to the function. I'd assume it's not submitting because your function is erroring out and thus stopping the button as if it were returning false. Fix your JavaScript, try using Firebug to help you find these problems.
Try adding an onsubmit to your form tag:
<form action="enterdb.php" method="post" enctype="application/x-www-form-urlencoded" onsubmit="return Checking(this);">
Then remove the onclick event from the submit button.
You need to pass a form object to the Checking function, hence the this. Also it's usually better to place the handler in the form tag as it'll be called when the user submits the form by either clicking the submit button or by pressing enter elsewhere in the form.
Edited per webdestroya.
generally, suggest that you comment out first clear.js and SpryValidationSelect.js, and then try run your code by adding one by one javascript file to clearly defined what is the file that been crashing with your inline code text.
also try to add name for your form and try like this:
function Checking(form){
if(empty(window.myform.fname.value){
alert("do nothing");
}
}
in a way to debug something, its best to try different method by which sometimes you will spot the not easier.
just my thought. gudluck