do not repeat values in databse during insertion using php and javascript
hello all, after tried so much now posting here. i have two programs sql.php and form.jsp. i want to do insert values into mssql database from user input form. sql.php is able to insert the values into database. i have connected database using ODBC.form.jsp is able to give user input form where user can enter name.
when i submit the name it will successfully stored into the database. but if i submit the same name also it will get stored. i don't want store same name twice in the database.and it should notify the user that name already exist in the database. i can't change my database schema to unique constraint.
i need to accomplish throgh program. how to give this validation ?
db.php
$connect = odbc_connect('SerDB','sa', 'pwd');
echo "server connected";
$query=("INSERT INTO namemb(name) VALUES ('$_POST[name]')");
$result = odbc_ exec($connect, $query);
form.jsp
<html>
<head>
<script type="text/javascript">
function validateForm()
{
var y=document.forms["myForm"]["name"].value;
if (y==null || y=="")
{
alert("name can be blank");
return false;
}
}
</script>
<body>
<form name="myForm" action="sql.php" onsubmit="return validateForm()"
method="post">
Name:<input type="text" name="name">
<input type="submit" value="Submit">
<input type="button" value="Cancel">
</form>
</body>
</html>
View Answers
Related Tutorials/Questions & Answers:
Advertisements
retrive article from sql databse and show using phpretrive article from sql
databse and show
using php hello sir
i have sql database which i store articles.i want to show these article on web page
using php. my field are image,title,summary,content id. plz provide me
Javascript and PHPJavascript and PHP Hello,
I want to know how to call
javascript function inside
PHP code .
Could you please tell me the way to call it?
Thanks
Here is a simple example of
php that calls
javascript function.
<
Insertion Sort In Java
In this example we are going to sort integer
values of an array
using
insertion
sort... .
Insertion sort is a good choice for small
values and for nearly-sorted
values... for large
values .
Positive feature of
insertion sorting:
PHP SQL Insertion PHP SQL
Insertion
PHP SQL
Insertion is used to execute MySQL queries in
PHP script..._TO_REPLACE_2
The
PHP SQL
insertion is saved with .
php extension. The server side
php do while syntaxphp do while syntax How to create a
do while loop in
php. What is the syntax
php do while loopphp do while loop Difference between
do while loop and simple loop in
PHP How to Display values from databse into tableHow to Display
values from
databse into table I want to display
values from database into table based on condition in query, how to display... enter either bookname or authorname and click on search button the
values from
Java repeat string without using loopsJava
repeat string without
using loops
In this section, you will learn how to
repeat string without
using for loops.
The given example accepts the number...
using while loop or any other control
statements.
Example:ADS_TO_REPLACE_1
php do while break php do while break receiving a Fatal saying cannot break/continue.. please suggest.
Thank U
javascript echo phpjavascript echo php i would like to know the complete syntax with the running example of
using JavaScript echo in
PHP.
Thanks
core java project by using databsecore java project by
using databse hello sir,
i'm a b.tech final year student.... i wantto make a project on java with database... can u plzz suggest me how i can start for it.... means on which topic i can make project
JavaScript in PHP LoopJavaScript in
PHP Loop i wants to know how to implement the
JavaScript code into the
PHP Loop function.
Thanks
Retrieve data from databse using where in JSPRetrieve data from
databse using where in JSP Hi, can somebody help me?
I have a jsp page. in that i want to get data from the database where username is matched. i tried it. but can't get the output.
here is the code. please
special set of tags do in PHP. special set of tags
do in
PHP. What does a special set of tags
do in
PHP?
Hi friends,
The special tag in
php is <?= ?>. This tag is used to diasplay the output directly on the browser.
Thanks
insert data into mysql databse using swinginsert data into mysql
databse using swing
Blockquote
hi,
here is my code,
i want code for store data into mysql database when click on submit button from access data from this form,
please provide code,
import java.awt.
PHP JavaScript form Validation - PHPPHP JavaScript form Validation Just looking for a general
PHP JavaScript form Validation. How can I write external
JavaScript Validation? Please suggest! Hi Friend,
1) form
Enter Name
Enter Address
php,javascript,htmlphp,
javascript,html Hi,
thank u for answered the previous question.
one more question:
when i register the student details, unique register number should be created and incresed automatically for every student based
Hiding form values using ajaxHiding form
values using ajax i am trying to show and hide form
values with ajax but it's not working,but in
javascript it is working.Can anyone will help me to the work in ajax please.
Thanks in advance
PHP Array Count ValuesPHP Array Count Values
Sometimes we need to count the number of
values, i.e. total number of appearance
of an element, in an array.
PHP provides... array
PHP Array Count
Values Example 1:
<?
php
$array=array("
PHP Functions and Return valuesPHP Functions and Return
values
A function is the a block of code whom you can...;
}
Given below the example :
<html>
<body>
<?
php...;
<?
php
function subtraction($a,$b)
{
$x=$a-$b;
return $x;
}
echo
PHP Insert Value');
Now to insert
values into table:
ii)
Using WAMP...
Insertion of data into table:
We will study in this tutorial how to insert data into a table
using MySQL
console and phpMyAdmin. After creating table we need
PHP Variables in JavaScriptPHP Variables in
JavaScript
JavaScript and
PHP both are scripting language... on the internet.ADS_TO_REPLACE_1
Let's see how can you use
PHP variables in
JavaScript.
For example of
PHP Variable in
JavaScript:
<title>
PHP
Variable
Insertion into databaseInsertion into database Hi,
I need code for inserting the multiple select box
values into database.Please
do send me the code.
Thanks for ur immediate replies its helping a lot
send mail using JavaScriptsend mail
using JavaScript How can we send mail
using JavaScript?
Hi friends,
You can not send email directly
using JavaScript.
But you can use
JavaScript to execute a client side email program send the email
using upload video using phpupload video
using php How to upload a video on MYSQL Server
using PHP Code..? Can any one provide me an example
How do i retain values in the drop down - StrutsHow
do i retain
values in the drop down Hi, I have a jsp page... with the drop down. My problem is whenever i
do this the
values in the drop down gets reset while the others in the text boxes don't. How
do i retain the
values PHP Returning Values from FunctionReturnig
Values from function:
From a function we can return
values using optional return statement, in
PHP
we can return arrays, objects. With the help... of the project. If we
do not put any return
statement then a NULL value is returned
insertion sortinsertion sort write a program in java
using insertion sort