I have several check boxes and when the multiple check box is clicked & form is submitted it goes in the db search for the corresponding result but it is giving me notice :
Warning: explode() expects parameter 2 to be string, array given in C:\xampp\htdocs\enoticeboard\home.php on line 68
this error is 3 times.
how I successfully retrieve it?
my code is:
<?php
include_once 'dbconfig.php';
if(!$user->is_loggedin())
{
$user->redirect('index.php');
}
$user_id = $_SESSION['user_session'];
$stmt = $DB_con->prepare("SELECT * FROM users WHERE user_id=:user_id");
$stmt->execute(array(":user_id"=>$user_id));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
<title>welcome -
<?php print($userRow[ 'user_email']); ?>
</title>
<style>
.left {
margin-left: 20px;
width: 100px;
}
</style>
</head>
<body>
<div class="header">
<div class="left">
<label><a>Welcome : <?php print($userRow['user_name']); ?></a> </label>
</div>
<div class="right">
<label><i class="glyphicon glyphicon-log-out"></i> logout
</label>
</div>
</div>
<div class="content">
<h1>Notice Board</h1>
<div class="left">
<h4>Select Hostel,Branch,Year</h4>
<form action="home.php" method="POST">
<label>Hostel</label>
<br/>
<input type="checkbox" name="hostel[]" value="K.P-1">K.P-1</input>
<br/>
<input type="checkbox" name="hostel[]" value="K.P-2">K.P-2</input>
<br/>
<input type="checkbox" name="hostel[]" value="K.P-3">K.P-3</input>
<br/>
<label>Branch</label>
<br/>
<input type="checkbox" name="branch[]" value="CSE">CSE</input>
<br/>
<input type="checkbox" name="branch[]" value="I.T">I.T</input>
<br/>
<input type="checkbox" name="branch[]" value="CIVIL">CIVIL</input>
<br/>
<label>YEAR</label>
<br/>
<input type="checkbox" name="year[]" value="2011">2011</input>
<br/>
<input type="checkbox" name="year[]" value="2012">2012</input>
<br/>
<input type="checkbox" name="year[]" value="2013">2013</input>
<br/>
<input type="submit" value="See Notices" />
</form>
</div>
<?php
if(isset($_POST['hostel']) && isset($_POST['branch']) && isset($_POST['year']))
{
if(!empty($_POST['hostel']) && !empty($_POST['branch']) && !empty($_POST['year']))
{
$arrayName = $_POST['hostel'];
$arrayName2 = $_POST['branch'];
$arrayName3 = $_POST['year'];
$hostel=explode(",",$arrayName);
$branch=explode(",",$arrayName2);
$year=explode(",",$arrayName3);
$stmt2=$DB_con->prepare("SELECT * FROM doc WHERE hostel=:hostel AND branch=:branch AND year=:year");
$stmt2->execute(array(':hostel'=>$hostel,':branch'=>$branch,':year'=>$year));
$userRow2=$stmt2->fetch(PDO::FETCH_ASSOC);
?>
<div class="middle">
<?php
if($userRow2 > 0){
foreach($userRow2['doc'] as $value2){
print_r($value2['doc']);
echo 'hi';
}
}
else {
echo "No records.";
}
?>
</div>
<?php
}
else {
echo "No Notice Found.";
}
}
else {
echo "Please fill in all fields.";
}
?>
</body>
</html>
explode() function splits string into array.
implode() function converts array into string.
So, it requires string as second parameter.
Your checkbox branch[] is already getting posted as array.
$_POST['branch'] is an array.
You do not need to explode() the checkbox array.
I think you need to combine array into a string.
So, use implode()
Just use:
$arrayName2 = $_POST['branch'];
$branch=implode(",",$arrayName2);
Instead of
$arrayName2 = $_POST['branch'];
$branch=explode(",",$arrayName2);
The warning is clear explode() requires parameter 2 be string, but you are passing array there. If you want to join array element with comma then you should use implode() as below :
$hostel=implode(",",$arrayName);
$branch=implode(",",$arrayName2);
$year=implode(",",$arrayName3);
Try this
if(isset($_POST['Submit'])) {
echo "<pre>";
print_r($_POST);
$checked = implode(',', $_POST['checkbox']);
echo $checked;
}
Related
I have a MySQL table named as letter and wish to insert records through the HTML data input form. Code as follows:
<head>
<meta charset="utf-8">
<link href="css/jquery-ui-1.10.1.css" rel="stylesheet">
<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui-1.10.1.min.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker(({ dateFormat: "yy-mm-dd" }));
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add Letter</title>
<style type="text/css" media="screen">
#import "style_contactform.css";
</style>
</head>
<?php
$querymethod = "select r_method_code, r_method from r_method order by r_method";
$resultmethod = mysql_query($querymethod) or die ( mysql_error());
$querybranch = "select bcode, branch from branch order by branch";
$resultbranch = mysql_query($querybranch) or die ( mysql_error());
$querytype = "select tcode, type from type order by type";
$resulttype = mysql_query($querytype) or die ( mysql_error());
?>
<?php
if (isset($_POST["submit"]))
{
$rno =$_POST["rno"];
$lno =$_POST["lno"];
$dol = mysql_real_escape_string($_POST["doi"]);
$hdg =$_POST["hdg"];
$from =$_POST["from"];
$address =$_POST["address"];
$method =$_POST["method"];
$type =$_POST["type"];
$branch =$_POST["branch"];
if ((empty($hdg))){
echo '<script language="javascript">';
echo 'alert("All fields must be required")';
echo '</script>';
}
else
{
$query ="INSERT INTO letter (reference_no, letter_no, date_stamp, heading, from_1, address, r_method_code, tcode, bcode) VALUES ('$rno', '$lno', '$dst', '$hdg', '$from', '$address', '$method', '$type', '$branch')";
$result = mysql_query($query) or die ( mysql_error());
$rc = mysql_affected_rows();
echo '<script language="javascript">';
echo 'alert("Added Successfully")';
echo '</script>';
}
}
?>
<html>
<form id="contactform">
<div class="formcolumn">
<label for="rno">Reference No:</label>
<input type="text" name="rno" />
<label for="lno">Letter No:</label>
<input type="text" name="lno" />
<label for="dst">Date of the Letter:</label>
<input type="text" name="dst" id="datepicker" />
<label for="hdg">Heading:</label>
<textarea name="hdg"></textarea>
</div>
<div class="formcolumn">
<label for="from">From 1:</label>
<input type="text" id="from" />
<label for="address">Address:</label>
<textarea id="address"></textarea>
<label for="method">Received Method:</label>
<select name="method" span class="al">
<?php
do {
?>
<option value="<?php echo $rowmethod['r_method_code']?>"><?php echo $rowmethod['r_method']?></option>
<?php
} while ($rowmethod = mysql_fetch_assoc($resultmethod));
?>
</select>
<label for="type">Type:</label>
<select name="type" span class="al">
<?php
do {
?>
<option value="<?php echo $rowtype['tcode']?>"><?php echo $rowtype['type']?></option>
<?php
} while ($rowtype = mysql_fetch_assoc($resulttype));
?>
</select>
<label for="branch">Branch:</label>
<select name="branch" span class="al">
<?php
do {
?>
<option value="<?php echo $rowbranch['bcode']?>"><?php echo $rowbranch['branch']?></option>
<?php
} while ($rowbranch = mysql_fetch_assoc($resultbranch));
?>
</select>
</div>
<div class="buttons">
<input class="button" type="submit" value="Submit!" />
</div>
</form>
</html>
But I was unable to add records through this form to the relevant table. I can not understand what I am going wrong. Can any one help me?... Pls...
Form's Attribute method's default value is get
You should specify it like this
<form id="contactform" method="post">
Now you can use $_POST to get data!
I have following code:
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<!--See siin all tekstiväli-->
<H3>Minu küsitlused </H3>
<hr>
<br>
<br>
<br>
<ol>
<?php
include_once 'init/init.funcs.php';
$result = mysql_query('SELECT * from katse_kysimustik_pealkiri');
while($row = mysql_fetch_assoc($result)) {
$titles[] = $row['pealkiri'];
}
foreach($titles as $title) {?>
<li>
<?php echo $title ?>
<form action='Minu_kysitlused_1.php' method="post">
<input type="submit" name = "saada" value="saada"/>
<input type="button" value="tulemused"/>
<input type="button" value="lõpeta ennetähtaegselt"/>
<input type="button" value="X"/>
</li>
</form>
<?php
}
?>
</ol>
</body>
</html>
<?php
if(isset($_POST['saada'])){
header("Location:http://localhost/Praks/saada.html");
}
?>
Right now there is button "saada" for each title in database. When I click "saada", page saada.html will appear.
This is saada.html
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Saada</title>
</head>
<form action="test1.php" method="POST">
<body>
<header>Küsitluse pealkiri</header>
<br>
Lisa sõnumile pealkiri:
<br>
<textarea rows='1' name='pealkiri'>Küsitluse algne pealkiri</textarea>
<br>
Lisa Adressaadid: <br>
<textarea rows='1' name='email'></textarea>
<br>
Lisa sõnum:
<br>
<textarea rows='4' name='tekst'></textarea>
<br><footer>
<INPUT TYPE="submit" VALUE="Saada" NAME="Saada">
</form>
<FORM METHOD="LINK" ACTION="Minu_kysitlused.html">
<INPUT TYPE="submit" VALUE="Loobu">
</footer>
</body>
</html>
My question is how could I make it work so value of $title appears in saada.html. The value of this $title which is next to 'saada' button I clicked. I need this value to be in this line instead of Küsitluse algne pealkiri:
<textarea rows='1' name='pealkiri'>Küsitluse algne pealkiri</textarea>
You can not have a value through PHP in HTML type page....change page extension to .php
then pass your $title in input hidden field in your form
like this
foreach($titles as $title) {?>
<li>
<?php echo $title ?>
<form action='Minu_kysitlused_1.php' method="post">
<input type="submit" name = "saada" value="saada"/>
<input type="button" value="tulemused"/>
<input type="button" value="lõpeta ennetähtaegselt"/>
<input type="button" value="X"/>
<input type="hidden" name="title" value="<?php echo $title;?>"/>
</li>
</form>
<?php
}
?>
Now set the cookie
<?php
if(isset($_POST['saada']))
{
if(isset($_REQUEST['title']))
{
$title = $_REQUEST['title'];
setcookie("page_title", $title, time()+3600);
}
header("Location:http://localhost/Praks/saada.html");
}
?>
Now on Your saada.html you can use js to retrieve cookie like this
JS Function Reference
var title = getCookie("page_title"); // retrieve cookie
document.getElementById('page_title').value = title; // put title into textaread
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
<textarea rows='1' name='pealkiri' id="page_title" >Küsitluse algne pealkiri</textarea>
I have a school project where I'm trying to use session variables to save a log in ID, however I can't seem to access the session variables across files. I'm relatively new to sessions, but have gotten them to work in simpler applications on the same server that I am using for this project. The program works as follows:
getData.php is the log in form where the user enters their ID and password.
front.php collects data from this form and forwards it to another server (of another group member) using php curl. Since this is not my part, I do not have this code.
After accessing a database, information from the database is forwarded back to me, also using curl and I format it in a table, in tList.php.
The problem is that the session variables do not seem to be accessible between the files on MY SERVER. The exact goal I am trying to accomplish is to access the session variables that I create in front.php on tList.php, however the variables are not set even though I assign them in front.php.
Any help would be greatly appreciated. Thank you.
getData.php:
<?php
session_start();
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" type="text/css" href="../css/b.css">
<link href="../css/test.css" rel="stylesheet" type="text/css">
</head>
<body>
<script type="text/javascript">
function status_toggle() {
if(document.getElementById('stud').checked) {
document.getElementById('sl').style.display='block';
document.getElementById('tl').style.display='none';
} else if(document.getElementById('teach').checked) {
document.getElementById('sl').style.display='none';
document.getElementById('tl').style.display='block';
}
}
</script>
<!-- Status Selection -->
<form name="radio" class="nav selection_form" action="" align="center">
<div align="center" class="">
Are you a <br>
Student <input id="stud" type="radio" name="status" value="student" onclick="javascript:status_toggle();" checked>
    or    
Teacher <input id="teach" type="radio" name="status" value="teacher" onclick="javascript:status_toggle();">
</div>
</form>
<!-- Student Form -->
<form id="sl" name="student_login" action="front.php" class="input-block my_form" autocomplete="on" method="post">
<div align="center">
Username: <input type="text" name="txtUCID" size="15" /><br />
Password: <input type="password" name="txtPasswd" size="15" /><br />
<p><input class="btn-red" id="submit" type="submit" value="Login" /></p>
</div>
</form>
<form style="display:none" id="tl" name="teacher_login" action="front.php" class="input-block my_form" autocomplete="on" method="post">
<div align="center">
Username: <input type="text" name="teacherTxtUCID" size="15" /><br />
Password: <input type="password" name="teacherTxtPasswd" size="15" /><br />
<p><input class="btn-grn" id="submit" type="submit" value="Login" /></p>
</div>
</form>
<div align="center" class="alert_box input-block my_form">
<h2 align="center" type="text" id="local_db"> change me!</h2>
<h2 align="center" type="text" id="njit_db"> change me!</h2>
</div>
</body>
</html>
front.php:
<?php
session_start();
$un = $_POST["txtUCID"];
$pw = $_POST["txtPasswd"];
$_SESSION['id'] = $un;
$curl = curl_init('web.njit.edu/~mc332/cs_490/loginSTD.php');
$postData= array(
'txtUCID' => $un,
'txtPasswd' => $pw
);
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 0,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_MAXREDIRS => 5
));
echo $_SESSION['id'];
$result = curl_exec ($curl);
curl_close ($curl);
tList.php
<?php
session_start();
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" type="text/css" href="list.css">
</head>
<body>
<div class="header">
Your Tests
</div>
<div class="list-view">
<?php
echo "SV: ".$_SESSION['id'];
$result = $_POST['tests'];
echo "<table>";
echo "<tr><th>Test ID</th><th>Test Name</th><th>Attempted</th><th>Score</th><th> Attempt Test </th></tr>";
$json = json_decode($result);
$i = 0;
while($i < count($json)) {
$id = $json[$i][0];
$name = $json[$i][1];
$tId = $id;
echo "<tr> <td> $id </td> <td> $name </td> <td> ? </td> <td> ?/100 </td> <td> <form method=\"post\" action=\"goToTest.php\" id=\"form$tId\"><button type=\"submit\">Take Test</button></input><input type=\"text\" style=\"display: none;\" name=\"poop\" value=\"$tId\"></input></form></td> </tr>";
$i++;
}
echo "</table>";
echo "end";
?>
</div>
</body>
</html>
Here is the working application:
file1:
<?php
session_start();
$_SESSION['test'] = "test";
echo "Click";
?>
file2:
<?php
session_start();
echo $_SESSION['test'];
?>
The session_start() function must appear BEFORE the tag
<?php session_start(); ?>
<html>
<body>
</body>
</html>
http://www.w3schools.com/php/php_sessions.asp
Try this to make sure you are passing valid values into the SESSION variable.
<?php
session_start();
if (!empty($_POST["txtUCID"])){
$_SESSION['id'] = $_POST["txtUCID"];
} else {
$_SESSION['id'] = 'no value set';
}
echo $_SESSION['id'];
I set up a PHP database that worked perfectly on my local server. Then, when I went to put it online through my hosting site, Site5, I was getting these kinds of errors: "Cannot modify header information – headers already sent by...". So I changed the PHP file on Site5 to have output buffering turned on. Now, I am not getting an error, however, whenever I input data, it doesn't echo it back - however, it does show up in the database in phpMyAdmin (but without an ID).
Any ideas as to why it isn't echoing back and why it's new data isn't getting an ID?
Here it is live (and broken):
http://hjaramillo.com/tell_me/index.php
<!DOCTYPE html>
<html class="no-js" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>A Message For You</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/media.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
</head>
<?php
ob_start();
//error_reporting(0);
require 'db/connect.php';
require 'functions/security.php';
error_reporting(E_ALL);
$records = array();
if(!empty($_POST)){
if(isset($_POST['first_name'],$_POST['location'],$_POST['message'])) {
$first_name = trim($_POST['first_name']);
$location = trim($_POST['location']);
$message = trim($_POST['message']);
if(!empty($first_name) && !empty($location) && !empty($message)) {
$insert = $db -> prepare("INSERT INTO message (first_name, location, message, date) VALUES (?,?,?,NOW())");
$insert->bind_param('sss',$first_name,$location,$message);
if($insert -> execute()){
header ('Location: index.php');
die();
}
}
}
}
if($results = $db->query("SELECT * FROM message ORDER BY id DESC LIMIT 1")) {
if($results->num_rows) {
while($row = $results->fetch_object()) {
$records[] = $row;
}
$results -> free();
}
}
?>
<?php
if (!count($records)){
echo 'No messages';
} else{
?>
<?php
foreach($records as $r){
?>
<body>
<?php
}}
?>
<div class="form-show">
<div class="post-icon">
<img src="images/post_icon.png"/>
</div>
</div>
<div class="form-background">
<div class="form-container">
<div class="form-title">
<p>Tell someone that:</p>
</div>
<form action="index.php" method="post">
<div class="fields msg">
<!--<label for="message">Message</label>-->
<textarea name="message" id="message" autocomplete="off"></textarea>
</div>
<div class="fields">
<ul>
<li> <label for="first_name">Name</label> </li>
<li> <input type="text" class="s-input" name="first_name" id="first_name" autocomplete="off"> </li>
</ul>
</div>
<div class="fields last">
<ul>
<li><label for="location">Location</label></li>
<li><input type="text" class="s-input" name="location" id="location" autocomplete="off"></li>
</ul>
</div>
<input type="submit" value="Post" id="submit-button">
</form>
<div>
</div>
</div>
</div>
<div class="msg-container">
<div class="msg-intro">
<p> On <?php echo escape($r->date); ?>,</p>
<p><span style="text-transform:capitalize;"><?php echo escape($r->first_name); ?> </span> from
<span style="text-transform:capitalize;"><?php echo escape($r->location); ?></span> wanted to tell you:</p>
</div>
<div class="msg-content">
<p><?php echo escape($r->message); ?></p>
</div>
</div>
</body>
<script type="text/javascript" src="js/application.js"></script>
</html>
Someone earlier asked if my ID was set to AUTO INCREMENT - it wasn't. That was the problem, thanks!
I'm unable to solve the logical error in the code. I'm not sure what is wrong though it seems the logic is correct
This is my php:
<?php require_once("includes/connection.php"); ?>
<?php
include_once("includes/form_functions.php");
if(isset($_POST['submit']))
{
$errors = array();
if(isset($_POST['txtSpace']))
{
$choice_spc_port = $_POST["txtSpace"];
}
if(isset($_POST['txtNumber']))
{
$choice_no = $_POST["txtNumber"];
}
if(isset($_POST['txtLocation']))
{
$choice_loc = $_POST["txtLocation"];
if($choice_loc =="txtSetXY")
{
$x = $_POST["txtXLocation"];
$y = $_POST["txtYLocation"];
if($x == "")
{
$message = "You forgot to enter X Value";
}
elseif($y == "")
{
$message = "You forgot to enter Y Value";
}
else
{
$choice_loc = $x . "," . $y;
}
}
}
$user_name = $_POST["txtUserName"];
$user_email = $_POST["txtUserEMail"];
$animal_name = $_POST["txtAnimalName"];
$disp_msg = $_POST["txtDispMsg"];
$comments = $_POST["txtComments"];
if(!isset($_POST['txtSpace']))
{
$message = "Please select Space Portion";
}
elseif(!isset($_POST['txtNumber']))
{
$message = "Please select the number of animals";
}
elseif(!isset($_POST['txtLocation']))
{
$message = "Please select the desired location of animal";
}
elseif($user_name == "")
{
$message = "Please enter your name.";
}
elseif($user_email == "")
{
$message = "Please enter your email.";
}
elseif($animal_name == "")
{
$message = "Please enter the name of the animal.";
}
elseif($disp_msg == "")
{
$message = "What message you want to dedicate to the animal?.";
}
else
{
// validation
$required_fields = array('txtUserName','txtUserEMail','txtAnimalName','txtDispMsg');
$errors = array_merge($errors, check_required_fields($required_fields, $_POST));
$user_name = trim(mysql_prep($_POST['txtUserName']));
$user_email = trim(mysql_prep($_POST['txtUserEMail']));
$animal_name = trim(mysql_prep($_POST['txtAnimalName']));
$disp_msg = trim(mysql_prep($_POST['txtDispMsg']));
if(empty($errors))
{
/*if($choice_loc == "txtSetXY")
{
$x = $_POST["txtXLocation"];
$y = $_POST["txtYLocation"];
$choice_loc = $x . "," . $y;
}*/
if($choice_no == "other")
{
$choice_no = $_POST["other_field"];
}
$insert = "INSERT INTO db_form (db_space_portion, db_number, db_location, db_user_name, db_user_email, db_animal_name, db_message, db_comments) VALUES ('{$choice_spc_port}', '{$choice_no}', '{$choice_loc}', '{$user_name}', '{$user_email}','{$animal_name}','{$disp_msg}','{$comments}')";
$result = mysql_query($insert);
if($result)
{
echo("<br>Input data is succeed");
}
else
{
$message = "The data cannot be inserted.";
$message .= "<br />" . mysql_error();
}
}
else
{
if(count($errors) == 1)
{
$message = "There was 1 error on the form.";
}
else
{
$message = "There were " . count($errors) ." errors on the form.";
}
}
}
}
else
{
$user_name = "";
$user_email = "";
$disp_msg = "";
$comments = "";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test Form</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css/layout.css" type="text/css" media="all">
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<script type="text/javascript" src="js/jquery-1.9.0.min.js" ></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/cufon-replace.js"></script>
<script type="text/javascript" src="js/Copse_400.font.js"></script>
<script type="text/javascript" src="js/imagepreloader.js"></script>
<script type="text/javascript" src="js/functions.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="js/ie6_script_other.js"></script>
<script type="text/javascript" src="js/html5.js"></script>
<![endif]-->
</head>
<body id="page5">
<!-- START PAGE SOURCE -->
<div class="body7">
<div class="main">
<section id="content">
<div class="wrapper">
<article class="col24">
<div class="pad1">
<h4>Kindly Fill the form</h4>
<?php if(!empty($message)){ echo $message; } ?>
<?php if(!empty($errors)){ echo display_errors($errors);}?>
<form id="TestForm" name="TestForm" method="post" action="form.php">
<div>
<div class="wrapper"> <strong><span>*</span> Desired Space</strong>
<div class="formText">
<input type="radio" name="txtSpace" value="RJ"/>Space Top<br />
<input type="radio" name="txtSpace" value="SM" />Space Bottom<br />
</div>
</div>
<div class="wrapper"> <strong><span>*</span> Select the Number</strong>
<div class="formText">
<input type="radio" name="txtNumber" value="100"/>100
<input type="radio" name="txtNumber" value="200"/>200
<input type="radio" name="txtNumber" value="500"/>500
<input type="radio" name="txtNumber" value="1000"/>1000
<input type="radio" name="txtNumber" value="10000"/>10000
<input type="radio" name="txtNumber" value="other"/>other
<input type="text" name="other_field" id="other_field" onblur="checktext(this);"/>
</div>
</div>
<div class="wrapper"> <strong><span>*</span> Select X & Y Value</strong>
<div class="formText">
<input type="radio" name="txtLocation" value="txtSetXY"/> Specify Photo Location<br />
<div style="padding-left:20px;">
X: <input type="text" id="locField" name="txtXLocation"><br />
Y: <input type="text" id="locField" name="txtYLocation"><br />
</div>
<input type="radio" name="txtLocation" value="Default"/>Default
</div>
</div>
<div class="wrapper"> <strong><span>*</span> Your Name:</strong>
<div class="bg">
<input type="text" class="input" name="txtUserName">
</div>
</div>
<div class="wrapper"> <strong><span>*</span> Your Email:</strong>
<div class="bg">
<input type="text" class="input" name="txtUserEMail">
</div>
</div>
<div class="wrapper"> <strong><span>*</span> Name of the animal:</strong>
<div class="bg">
<input type="text" class="input" name="txtAnimalName">
</div>
</div>
<div class="wrapper">
<div class="textarea_box"> <strong><span>*</span> The Message you want for your favourite animal:</strong>
<textarea name="txtDispMsg" cols="1" rows="1"></textarea>
</div>
</div>
<div class="wrapper">
<div class="textarea_box"> <strong>Comments:</strong>
<textarea name="txtComments" cols="1" rows="1"></textarea>
</div>
</div>
<input type="submit" name="submit" value="Submit">
</div>
</form>
</div>
</article>
</div>
</section>
</div>
</div>
</body>
</html>
Errors:
Check this php fiddle here.
line 25. This is never shown even if I leave x textfield blank
$message = "You forgot to enter X Value";
same is with line 29. This is never shown even if I leave y textfield blank
$message = "You forgot to enter Y Value";
However if I enter the values in x and y textfield i.e. in txtXLocation and in txtYLocation they are being saved in db meaning it is just not checking the validation.
Thanks in advance
make sure you have connection.php file in includes folder and you have given correct path to reach that file.