How to validate all rows in a table using PHP


adapar
26/4/2016 6:52 am
HOME ยป Web Development

below is the script where i am trying to validate if the same name, id and email exists in a table, the problem is that even if i add a new input for each field i still get a "data already exist", how do i fix this issue, also how to validate using regular expression for each fields..for id i need three letters and 3 numbers using regular expression

if(isset($_POST['register'])){

//Retrieve the field values from our registration form.
$name = !empty($_POST['name']) ? trim($_POST['name']) : null;
$ccode = !empty($_POST['id']) ? trim($_POST['id']) : null;
$email = !empty($_POST['email']) ? trim($_POST['email']) : null;

$sql = "SELECT COUNT(*) AS num FROM users";
$stmt = $pdo->prepare($sql);


$stmt->bindValue(':name', $name);
$stmt->bindValue(':id', $id);
$stmt->bindValue(':email', $email);

$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_ASSOC);


if($row['num'] > 0){
die('The Data already exists!');
}

else{

$sql = "INSERT INTO users (name, id, email) VALUES (:name, :id,  
:email)";
$stmt = $pdo->prepare($sql);


$stmt->bindValue(':name', $name);
$stmt->bindValue(':id', $id);
$stmt->bindValue(':email', $email);


$result = $stmt->execute();


if($result){
echo 'User aadded successfully!';
}
} 
}


<form action="sign.php" method="post">
<label for="name">Name</label>
<input type="text" id="name" name="name" required><br>
<label for="id">id</label>
<input type="text" id="" name="id" required><br>
<label for="email">Email</label>
<input type="email" id="email" name="email" required><br>
<input type="submit" name="register" value=" Click to
Add"></button>
</form>

and how do i validate if the fields have same name., for example i have 3 input fields, in the first field i enter the name of a person and in the second or third field if i enter the same name an error should display when i click the submit button, can it be done using a for loop to check each field if it contains the same name


Related to : How to validate all rows in a table using PHP
How to validate all rows in a table using PHP
26/4/2016 6:52 am by adapar in Web Development

below is the script where i am trying to validate if the same name, id and email exists in a table, the problem is that even if i add a new input for each field i still get a "data already exist", how do i fix this issue, also how to validate using regular expression for each fields..for id i nee


JavaScript Form Validate rows in HTML table
by rajiv in Web Development

For some reasons my javascript form validation does not go through every row in the table.
I created the table with the codes below:
The $usr variable is just a result of another process:


<form name="myForm" action="addAccessories.php" method="post" onsubmit="return
Modify htaccess, to redirect index.php to folder/index.php
31/3/2016 3:42 pm by Jpark in Web Development

Here is what I currently have in the .htaccess file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

I am trying to make it so when a visiter visits the website: www.example.com instead of lo


How do I select rows in table (A) sharing the same foreign key (itemId) where multiple rows in table have the values in table B
by HtW in Web Development

Sorry about the title, not sure how to describe without example. I trying to implement faceting of attributes in SQL Server 2008.


I have 2 tables. itemAttributes and facetParameters


Assume the following values in itemAttributes


id, itemId, name, val
XML.load('my_xml.php') Vs XML.sendAndLoad(xml, 'my_xml.php')
by Ernie in Web Development

Hi guys, was wondering if someone could give me some insight into this. I have a php script which returns xml content, and initially i was using this script as my xml source in the XML.load() method. However, i noticed that occassionally the xml wouldn't load. Is it possible Flash is trying to load
Excel Macro selects entire table rows, cuts and pastes to another table, then deletes original rows
by skriefal in Web Development

I'm trying to create a macro that will do the following:


Recognize my active cell(s) and select the entire table row(s) of
those cell(s). Cut all of those rows.
Paste them into another table on a different worksheet (at the end
of the table to add on to whatever is already
Create one table out of thousands, the same number of columns, varied rows, copy heading into rows of respective table
by Scott Smith in Web Development

I have a few hundred tables each with their own heading, these tables are all on one worksheet, the tables have a varying number of rows and the same number of columns. I want to copy the heading from each table onto each row in the table that it belongs to. Essentially adding a column entitled "


Jquery Templates - append table rows inside table element and clear any existing rows first
by LinAdmin in Web Development

I have a template that looks like this:


<div id="PopUpTemplate" style="display: none">
<tr><td>${Key}</td><td>${Value}</td></tr>
</div>

and I want to append it into a table :


<div i
How do I dynamically update rows in the new MySQL table with dynamic data populating the rows in the old table?
by gitano in Web Development

I have the following SQL code that works fine for transferring rows of data from the old table to the new table. (working in MySQL workbench)


INSERT INTO us_compensation.RPBAR
(ORG_SEC_ID ,
FYE,
TOTAL_SALARY_PAID ,
OTHER_COMP_PAID ,
TOTAL_BONUS_PAID , TAGS: dynamically update rows MySQL table with
two sql tables having 197000 rows in word table and second is wp_posts contains 60000 rows want to subtract second second table from first?
by Pat in Web Development

i have many searched on google for this from last 3 days got many solution but not efficient works for small databases ;


like below


SELECT title FROM word o
WHERE NOT EXISTS (SELECT 1
FROM wp_posts c
WHERE c.post_title = o.title)

Pl




HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .