Form Validation Error Message not showing - php

Was hoping for some fresh eyes on this. I've got a page which will add a new event to a database. All 3 fields are required, so if they are empty when the submit button is pushed the error message should appear. Anyone know why it isn't showing the error message? Thanks in advance!
Here's the code:
<!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" xml:lang="en" lang="en">
<head>
<title>ADMIN - Repetative Strain Injury UK</title>
<meta http-equiv="content-type" content="application/xhtml; charset=utf-8" />
<link href="/iis_project/view/css/mycss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<!-- wrapper div for positioning -->
<div class="grid10 first" id="header">
<!-- Header Section -->
<img src="/iis_project/view/img/banner.jpg" alt="RSI UK Banner" width="1090" height="75"/>
</div>
<div class="grid11 first" id="date">
<!-- Date Section -->
<?php
include ("date.php");
?>
</div>
<div class="grid2 first" id="col1">
<!-- Left column Section -->
<h1>Navigation</h1>
<p>
<strong>Home</strong>
</p>
<p>
<strong>About Us</strong>
</p>
<p>
<strong>Register</strong>
</p>
<p>
<strong>Log In</strong>
</p>
<p>
<strong>Events</strong>
</p>
<p>
<strong>Acknowledgements</strong>
</p>
</div>
<div class="grid6" id="col2">
<!-- Middle column Section -->
<h1>New Event</h1>
<p>
As an admin you have the right to create a new event. Simply fill out the form below and hit submit.
</p>
<?php
// creates the new record form
// since this form is used multiple times in this file, I have made it a function that is easily reusable
function renderForm($name, $date, $location, $error22)
{
?>
<?php
// if there are any error22s, display them
if ($error22 != '') {
echo '<div style="padding:4px; border:1px solid red; color:red;">' . $error22 . '</div>';
}
?>
<form action="" method="post">
<div>
Name:
<input type="text" name="name" value="<?php echo $name;?>" />
<br/>
Date:
<input type="text" name="date" value="<?php echo $date;?>" />
<br/>
Location:
<input type="text" name="location" value="<?php echo $location;?>" />
<br/>
<input type="submit" name="submit_event" value="Submit">
</div>
</form>
<?php
}
// connect to the database
include ("home_connection.php");
// check if the form has been submitted. If it has, start to process the form and save it to the database
if (isset($_POST['submit']))
{
// get form data, making sure it is valid
$name = mysql_real_escape_string(htmlspecialchars($_POST['name']));
$date = mysql_real_escape_string(htmlspecialchars($_POST['date']));
$location = mysql_real_escape_string(htmlspecialchars($_POST['location']));
// check to make sure all fields are entered
if ($name == '' || $date == '' || $location == '')
{
// generate error22 message
$error22 = 'error22: Please fill in all required fields!';
// if either field is blank, display the form again
renderForm($name, $date, $location, $error22);
}
else
{
// save the data to the database
mysql_query("INSERT events SET name='$name', date='$date', location='$location'")
or die(mysql_error22());
// once saved, redirect back to the view page
header("Location: login_success_admin.php");
}
}
else
// if the form hasn't been submitted, display the form
{
renderForm('','','','');
}
?>
</div>
<div class="grid2" id="col3">
<!-- Right column Section -->
<h1>Newsletter</h1>
<h2>Sign up to our newsletter:</h2>
<?php
include ("newsletter.php");
?>
</div>
<div class="grid10 first" id="footer">
<!-- Footer Section -->
<p>
Repetative Strain Injury UK © West Street, Jubille Way, Leeds, LS6 3QW. Email: info#rsiuk.org
Tel: 0113 658102. Reg charity no: 1032941
</p>
</div>
</div> <!-- end container -->
</body>
</html>

You have the submit name as "submit_event"
So you must use
if (isset($_POST['submit_event'])) {
.
.
.
}
Hope it helps

Try adding
<input type="hidden" name="submit" value="1" />
to your form. The $_POST array does not have a 'submit' value in the code you have provided, so it's just going to display the form again.

Related

PHP Checkbox Values Not Saved During Error Check or Posting

The "newvar_" values for "029, 032 and 033" are not being remembered during error-checking, nor are they being posted when a corrected form is submitted.
The "name" field works correctly both on error checking and posting.
The form default for the all checkboxes is not selected.
The user should be able to select only the forms they wish. Their selection should post to the txt file along with their name.
The validation library am using can be found at: http://www.benjaminkeen.com/software/php_validation
Thanks in advance for your assistance.
<?php
// Eliminate server error notices except for parse errors
error_reporting(E_PARSE);
// Receiving variables
$errors = array(); // set the errors array to empty, by default
$fields = array(); // stores the field values
if (isset($_POST['submit']))
{
// Import the validation library
require("../include/validation.php");
$rules = array(); // stores the validation rules
// Rules specific to this form
$rules[] = "required,name,Please enter Your Name.";
$rules[] = "length<71,name,Your Name is too long.";
// Check the user's entries for errors based upon above rules
$errors = validate_fields($_POST, $rules);
// If there were errors, re-populate the form fields with user entries
if (!empty($errors))
{
$fields = $_POST;
}
// If there were no errors
else
{
// Redirect to a "thank you" page URL shown below
header("Location: thank-you.php");
}
}
// Count the errors. If none process the form data
if (count($errors) == 0) {
// Location of flat file database - absolute path
$datafile_01 = '/home/domain/public_html/Forms.txt';
// Strip-out the HTML tags
$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
// Write successfully submitted form data to flat file database
if ($_POST['submit']) {
$file = fopen($datafile_01, "a");
if (!$file) {
die("Can't write to database file");
}
// Set timezone to match delivery location
date_default_timezone_set('America/New_York');
$date = date('Y m-d g:i:s a');
// Select and code the fields being posted
$name = $_POST['name'];$name=($name);
//FORMS & SUPPLIES
// Standard Forms they requested
// Change the checkbox 'on' to something else (defined by $Newvar)
if($Form_F_029 == 'on') { $Newvar_029 = &$Form_F_029; $Newvar_029 = "X"; }
if($Form_F_032 == 'on') { $Newvar_032 = &$Form_F_032; $Newvar_032 = "X"; }
if($Form_F_033 == 'on') { $Newvar_033 = &$Form_F_033; $Newvar_033 = "X"; }
// Format the fields for the flat file
fwrite($file,
"Name:\t $name\n
REQUESTED FORMS AND SUPPLIES:\n
STANDARD FORMS ++++++++++++++++++++
Form F-029:\t $Newvar_029
Form F-032:\t $Newvar_032
Form F-033:\t $Newvar_033\n
=============================================================================== EOF =\n\n);"
fclose($file);
}
// Format and send email notice of successful submittal
if ($_POST['submit']) {
$sn_header = "From: Inquiries Database\n"
. "Reply-To: no_reply#domain.com\n";
$sn_subject = "Ordering Supplies Request";
$sn_email_to = "someone#domain.com";
$sn_message = "Please check the database for a recent submission.\n\n"
. "This is a post-only message.\n\n"
. "Do not reply.\n";
#mail($sn_email_to, $sn_subject ,$sn_message ,$sn_header ) ;
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Form Test</title>
<meta charset="utf-8" />
<meta name="viewport"
content="width=device-width, initial-scale=1" />
<?php //This CSS needed only for forms to style Modal ?>
<link rel="stylesheet"
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"
media="screen" />
</head>
<body>
<!-- Wrapper -->
<div id="wrapper" class="divided">
<section class="wrapper style1 align-left">
<div class="inner">
<h2 class="color-1">Measuring & Ordering Supplies</h2>
<form action="<?=$_SERVER['PHP_SELF']?>" name="inquiry" method="post">
<div class="field">
<label style="margin:1rem 0 .25rem 0"><i class=" color-1 fa fa-star"></i> Your Name:</label>
<input type="text" name="name" id="name" value="<?=$fields['name']?>" />
</div>
<div class="field" style="padding-top:1rem">
<label style="font-size:110%; margin-bottom:0"><b class="color-1">Standard Forms</b>
<span style="font-weight:300; font-size:80%">Check box to order | Click name to download PDF</span><br />
</label>
</div>
<div class="field third first" style="padding-top:10px">
<input type="checkbox" id="Form_F_029" name="Form_F_029" <?php if($Form_F_029 == "on"){echo "CHECKED";}?> />
<label for="F_029">Form F 029
</label>
</div>
<div class="field third" style="padding-top:10px">
<input type="checkbox" id="Form_F_032" name="Form_F_032" <?php if($Form_F_032 == "on"){echo "CHECKED";}?> />
<label for="Form_F_032">Form F 032
</label>
</div>
<div class="field third" style="padding-top:10px">
<input type="checkbox" id="Form_F_033" name="Form_F_033" <?php if($Form_F_033 == "on"){echo "CHECKED";}?> />
<label for="Form_F_033">Form F 033
</label>
</div>
<ul class="actions" style="padding-top:30px">
<li><input type="submit" class="button small" name="submit" id="submit" value="Submit Request" /></li>
</ul>
</form>
</div>
<div id="error" title="Form Errors:">
<?php
// if $errors is not empty display them in the modal
if (!empty($errors))
{
echo "<div style=\"padding:15px 15px 0 15px\">";
echo "<ul style=\"margin-bottom:20px\">";
foreach ($errors as $error)
echo "<li style=\"font-size:15px; padding:5px\">$error</li>";
echo "</ul></div>";
}
?>
</div>
</section>
<!-- Footer -->
</div>
<!-- Scripts -->
<?php include $_SERVER["DOCUMENT_ROOT"] . "/assets/includes/php/javascripts-01.php"; ?>
<?php // Supporting scripts for Error Modal ?>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
<?php if( isset( $_POST["submit"] ) ){ ?>
$('#error').dialog({
height: 380,
width: 260,
modal: true,
resizable: false,
dialogClass: 'no-close error-dialog'
});
<?php } ?>
</script>
</body>
</html>
The values of $Form_F_029, _032, _033 are never set.
You copied the POST variables into $fields:
$fields = $_POST;
So this worked as intended:
<input type="text" name="name" id="name" value="<?=$fields['name']?>" />
But uses of $Form_F_0xx are treated as null, undefined or false depending on context:
<input type="checkbox" id="Form_F_029" name="Form_F_029" <?php if($Form_F_029 == "on"){echo "CHECKED";}?> />
You could fix this by setting
$Form_F_029 = $fields['Form_F_029'];
or
$Form_F_029 = $_POST['Form_F_029'];
etc.
For debugging problems like this it can help to include the values of variables and arrays in your output, for example in a comment or pre tag:
echo "<!-- 29= $Form_F_029, 32 = $Form_F_032 -->"; // DEBUGGING
echo "<pre>- 29= $Form_F_029, 32 = $Form_F_032 </pre>"; // DEBUGGING
Just remember to delete them or comment them out later.

passing id on href and submitting form on same page

I am making social project form and im trying to add reply ..the reply button is a link that sends user to reply.php page with post id saved in href...on the reply.php my form action is the same page but when i click button to submit form it doesnot get the id and refreshes page with post and display error undefined id need help..
here is my reply.php
<?php
require('session.php');
$id=$_GET['id'];
//echo $id;
$submit=#$_POST['submit'];
$reply=#$_POST['reply'];
if(isset($submit)){
$id=#$_GET['id'];
$sql=mysqli_query($con,"INSERT INTO REPLY (reply,Username,post_id) VALUES '$reply','$user_check','$id'");
$sql2=mysqli_query($con,"SELECT * FROM REPLY WHERE post_id= '$id'");
while($row=mysqli_fetch_array($sql2)){
echo $row['Username']."<br/>".$row['reply']."<br/>";
}
}
else "error in submission";
?>
<!DOCTYPE html>
<html>
<title>Studhelp</title>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="w3.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<script src="bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<?php
$sql=mysqli_query($con,"select * from posts where post_id='$id'");
while($row=mysqli_fetch_array($sql)){?>
<!-- Middle Column -->
<div class="w3-col m7">
<div class="w3-row-padding">
<div class="w3-col m12">
<div class="w3-card-2 w3-round w3-white">
<div class="w3-container w3-padding">
<h3 class="w3-opacity"><?php echo $row['Username'] ;?></h3>
<?php
echo $row['Posts']."<br/>".$row['date']."<br/>";
}
?>
</p>
</div>
</div>
</div>
</div>
<form action="reply.php" method="post">
<input type="text" name="reply" >
<input type="submit" name="submit" value="reply">
</form>
this is the anchor tag send id to reply.php
Reply
If I understand correct you need to be able to read your "id" variable after you post the form. To achieve this use $_REQUEST instead of $_GET, like this:
$id = $_REQUEST['id'];
And also pass the variable with your form, as a hidden field:
<form action="reply.php" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="text" name="reply" />
<input type="submit" name="submit" value="reply" />
</form>
You didn't check if the fom was submitted
Enclose other PHP code after session.php inside a conditional checker such as:
if ($_POST):
You can use form tags to create a form and put the id field as hidden.
GET requests shouldn't be use to modify data

How do I check which input button has been pressed in PHP?

so I'm new to php and I have two buttons on this html page here (the id value is included in the url):
<!DOCTYPE html>
<head>
<title>StoryBlox is a Social Story Builder Tool</title>
<meta charset="utf-8">
<!-- these support the header/footer formatting -->
<link type="text/css" rel="stylesheet" href="css/main.css">
<link type="text/css" rel="stylesheet" href="css/header_footer.css">
<script src="js/header.js"></script>
<?php //include_once 'confirm_login.php'
include_once 'story_manager.php';
include_once 'open_connection.php';
//include_once 'functions.php';
//sec_session_start();
if(isset($_GET['id'])){
$str_id = $_GET['id'];
$draft_id = get_story_attribute($str_id, 'draft');
}else{
echo "Invalid story id.";
echo "<br>";
}
?>
</head>
<body>
<div id="wrapper_main">
<div id="wrapper_content">
<?php include_once 'header.php'; ?>
<h1>Welcome to StoryBlox Create Story!</h1>
</div>
<!-- menu -->
<!--<div id="inputs"> -->
<form id="create_form" action="save_story.php?id=<?php echo $str_id?>" method="POST">
<input type="text" name="storyTitle" id="title" placeholder="Enter title." autofocus/><br>
<textarea rows="4" cols="50" name="storyDesc" id="description" placeholder="Enter description here."></textarea>
<div id="footer">
<input type="button" name="draftBtn" onclick="this.form.submit()" value="Save as Draft"/>
<input type="button" name="finalBtn" onclick="this.form.submit()" value="Finished!"/>
</div>
</form>
</div>
</div>
<?php include_once 'footer.php'; ?>
</body>
When I click one of these two buttons, I'm brought to this php document here:
include_once 'open_connection.php';
include_once 'story_manager.php';
$mysqli = open_connection();
if($_SERVER['REQUEST_METHOD'] === 'POST'){
if(isset($_POST['draftBtn'])){
$title = $_POST['storyTitle'];
$desc = $_POST['storyDesc'];
$str_id = $_GET['id'];
update_story_title($str_id, $title);
//update_story_description($str_id, $desc);
header('Location: createStory.php');
}
elseif(isset($_POST['finalBtn'])){
$title = $_POST['storyTitle'];
$desc = $_POST['storyDesc'];
$str_id = $_POST['storyID'];
update_story_title($str_id, $title);
//update_story_description($str_id, $desc);
save_draft_as_completed($str_id);
header('Location: ../home.php');
}else{ echo "failed";}
}?>
And I always get "failed" printed out on my page. I've been Googling this for hours and I don't understand where I'm going wrong here. If anybody could help that would be appreciated. Also, if anyone could shed some light on what the equivalent to
<input type="textarea">
would be that would be great. Thanks!
Use
<input type="submit" name="draftBtn" value="Save as Draft"/>
instead of the button types with their onclick events.
try to use submit tag instead of button.
and if you want to use button tag then you can pass value through hidden field. set value of hidden field on click event.

PHP contact form not working and giving errors

I am trying to set up a contact form at:
http://48hrcodes.com/contact.php
however I am trouble getting it to work.
Here is the code I am using:
<?php
/**
* Change the email address to your own.
*
* $empty_fields_message and $thankyou_message can be changed
* if you wish.
*/
// Change to your own email address
$your_email = "";
// This is what is displayed in the email subject line
// Change it if you want
$subject = "48hrcodes contact form";
// This is displayed if all the fields are not filled in
$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>";
// This is displayed when the email has been sent
$thankyou_message = "<p>Thank you. Your message has been received.</p>";
// You do not need to edit below this line
$name = stripslashes($_POST['txtName']);
$email = stripslashes($_POST['txtEmail']);
$message = stripslashes($_POST['txtMessage']);
if (!isset($_POST['txtName'])) {
?>
<html lang="en">
<head>
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/style.css">
<title>Free 48hr Xbox Live Gold Codes</title>
</head>
<body>
<div id="content">
<div id="c1"> <center>
<header id="nav">
<ul>
<li>Home</li>
<li>Get Your Code</li>
<li>Testimonials and Proof</li>
<li>Frequently Asked Questions</li>
<li>Contact Us</li>
</ul>
</header>
<img class="clear" src="img/grab3.png" alt="header">
</center>
<form class="form" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<p class="name">
<input type="text" name="txtName" id="name" placeholder="John Doe" />
<label for="name">Name</label>
</p>
<p class="email">
<input type="text" name="txtEmail" id="email" placeholder="mail#example.com" />
<label for="email">Email</label>
</p>
<p class="text">
<textarea name="txtMessage" placeholder="Write something to us" /></textarea>
</p>
<p class="submit">
<input type="submit" value="Send" />
</p>
</form>
<div id="cttxt">
<h3>
Contact Us
</h3>
<p>
Simply send us message using the contact form to the left and we will get back to you within 24-48 hours.
</p>
</div>
<center>
<footer>
© 48hrcodes.com 2013 - site by ollie rex
</footer>
</div></center>
</div>
</body>
</html>
<?php
}
elseif (empty($name) || empty($email) || empty($message)) {
echo $empty_fields_message;
}
else {
// Stop the form being used from an external URL
// Get the referring URL
$referer = $_SERVER['HTTP_REFERER'];
// Get the URL of this page
$this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
// If the referring URL and the URL of this page don't match then
// display a message and don't send the email.
if ($referer != $this_url) {
echo "You do not have permission to use this script from another URL, nice hacking attempt moron.";
exit;
}
// The URLs matched so send the email
mail($your_email, $subject, $message, "From: $name <$email>");
// Display the thankyou message
echo $thankyou_message;
}
?>
I get errors at the top of the page, as well as when i submit the form, the email i get only has the messagebox text, not the name or email.
I have tried everything i could think of, however it still fails to send anything except the msg variable.
Thanks :)
change
$name = stripslashes($_POST['txtName']);
$email = stripslashes($_POST['txtEmail']);
$message = stripslashes($_POST['txtMessage']);
To,
$name = (isset($_POST['txtName']))?stripslashes($_POST['txtName']):"";
$email = (isset($_POST['txtEmail']))?stripslashes($_POST['txtEmail']):"";
$message = (isset($_POST['txtMessage']))?stripslashes($_POST['txtMessage']):"";
To avoid the warnings at the top.
Use
like this
if(isset($_POST['txtName'])
{
$name = stripslashes($_POST['txtName']);
}

Form validator endpoint not found

I'm trying to write a form for User Information to keep track of who downloads files from my website.
I downloaded a PHP form validator from this website and I tried to mimic the example 3 with client-side validation and here is what I came up with (please excuse the length, but I figured it was necessary for understanding everything):
<?php
require_once(ABSPATH. '/wp-includes/FormValidator/include/formvalidator.php');
$validation_errors='';
if(isset($_POST['submitButton']))
{// We need to validate only after the form is submitted
//Setup Server side Validations
//Please note that the element name is case sensitive
$validator = new FormValidator();
$validator->addValidation("firstname","req","Please fill in your First Name");
$validator->addValidation("firstname","alpha","Only letters a-z/A-Z are allowed for your First Name");
$validator->addValidation("lasttname","req","Please fill in your Last Name");
$validator->addValidation("lastname","alpha","Only letters a-z/A-Z are allowed for your Last Name");
//Then validate the form
if($validator->ValidateForm())
{
//If the validations succeeded, proceed with form processing
addUserDataToDB();
}
else
{
//Validations failed. Display Errors.
$error_hash = $validator->GetErrors();
foreach($error_hash as $inpname => $inp_err)
{
$validation_errors .= "<p>$inpname : $inp_err</p>\n";
}
}
}//if
$first_name = isset($_POST['firstname'])?$_POST['firstname']:'';
$last_name = isset($_POST['lastname'])?$_POST['lastname']:'';
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Whitepaper Download User Info</title>
<style type="text/css">
.error
{
font-family: Verdana, Arial, sans-serif;
font-size: 0.7em;
color: #900;
background-color : #ffff00;
}
</style>
<script type='text/javascript' src='<?php echo ABSPATH.'/wp-includes/FormValidator/scripts/gen_validatorv31.js' ?>'>
</script>
</head>
<body>
<form id="DownloadUserDataForm" style="width:100%;">
<fieldset>
<div style="width:100%;">
<p><b>Input Fields with (*) are Required.</b> <br/><p>
<div>
<span class='error'><?php echo $validation_errors; ?></span>
</div>
<div style="width:100%;">
<div style="display:inline-block; float:left; width:48%; margin-right:5px;">
<b>First Name *:</b> <input type="text" name="firstname" style="width:82%;" maxlength="50" <?php if (isset($errors)) { echo 'value="'.htmlentities($_POST['first_name']).'"'; }?>
/> <br />
<span id='firstname_errorloc' class='error'></span>
</div>
<div style="display:inline-block; float:left; width:48%;">
<b>Last Name *:</b> <input type="text" name="lastname" maxlength="50" style="display:inline-block; width:82%;" <?php if (isset($errors)) { echo 'value="'.htmlentities($_POST['last_name']).'"'; } ?> /><br/>
<span id='lastname_errorloc' class='error'></span>
</div>
</div>
<br />
<div class="clear:both;">
<p><input type="submit" name="submitButton" value="Submit" style="clear:both;" /></p>
</div>
</div>
</fieldset>
</form>
</body>
</html>
<?php
//Function for Processing Data
function addUserDataToDB()
{
global $wpdb;
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$rows_affected = $wpdb->insert( 'wp_downloadUserData', array( 'time' => current_time('mysql'), 'firstname' => $firstname,
'lastname' => $lastname ) );
//Redirect to download page
wp_redirect('Whitepaper.htm');
exit();
}
?>
<!-- client-side Form Validations:
Uses the form validation script from JavaScript-coder.com
See: http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
-->
<script type='text/javascript'>
console.log("javascript ran");
var frmvalidator = new Validator("DownloadUserDataForm");
frmvalidator.EnableOnPageErrorDisplay();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("firstname","req","Please fill in your First Name");
frmvalidator.addValidation("firstname","alpha","Only letters a-z/A-Z are allowed for your First Name");
frmvalidator.addValidation("lasttname","req","Please fill in your Last Name");
frmvalidator.addValidation("lastname","alpha","Only letters a-z/A-Z are allowed for your Last Name");
</script>
All that happens is the page refreshes, no errors or validations, and it doesn't seem to write to $wpdb because I have an admin page that queries the db table and it comes up empty (it also doesn't wp_redirect() like it should). Also for some reason it cannot find the javascript file even though the address looks correct.
GET
http:///home/public_html/wp-includes/FormValidator/scripts/gen_validatorv31.js
404 (Not Found)
For your javascript error try changing this line:
<script type='text/javascript' src='<?php echo ABSPATH.'/wp-includes/FormValidator/scripts/gen_validatorv31.js' ?>'>
to
<script type="text/javascript" src="<?php echo ABSPATH; ?>/wp-includes/FormValidator/scripts/gen_validatorv31.js"></script>

Categories