ghjk 250
Contributor
I have a web page developed using php and postgres. There I have a page for user administration( add user). If user fill all information and click submit button I want to send those values to ajax file and validate and insert to the DB. I passed value to the ajax file and I want to send validated values to php file to insert to the DB. How can I do that? Plase help me.
This is my php file. -
if(isset($_POST['submit'])){
-
$array = array('FullName'=>'FullName','Gender'=>'Gender','PhnNo' =>'PhoneNumber', 'Email' =>'EmailAddress',);
-
foreach ($array as $key => $val)
-
$$key = $_POST[$val];
-
-
$pgsql = "insert into \"User\" ( \"Name\" , \"Phone\" , \"PtntEmail\",\"Gender\" )
-
VALUES ('$FullName', '$PhnNo', '$Email','$Gender');";
-
echo $pgsql;
-
$result = pg_query($dbconn , $pgsql);
-
if (!$result) {
-
die("Error in SQL query: " . pg_last_error());
-
}
-
-
echo "Data successfully inserted!";
-
}
-
-
?> <form name="user.php" id="user.php" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
-
<tr>
-
<td height="24" colspan="3" ><!--DWLayoutEmptyCell--> </td>
-
</tr>
-
<tr>
-
<td height="24" >Full Name*</td>
-
<td colspan="2"><input type="text" name="FullName" size="40" ></td>
-
</tr>
-
-
<tr>
-
<td>Gender</td>
-
<td width="69"><input name="Gender" name="Male" type="radio" value="1"/> Male</td>
-
-
<td width="297" ><input name="Gender" name="Female" type="radio" value="2" />Female </td>
-
</tr>
-
-
<tr>
-
<td>Phone Number*</td>
-
<td colspan="2"><input type="text" name="PhoneNumber" /></td>
-
</tr>
-
-
<tr>
-
<td>Email Address</td>
-
<td colspan="2"><input type="text" name="EmailAddress" /></td>
-
</tr>
-
-
</tr>
-
-
<tr>
-
<td> </td>
-
<td colspan="2" align="right">
-
-
<input id="submit" src="submit.jpg" type="image" alt="submit" height="30" width="73" onclick="javascrpit:pages(); return false" />
-
-
<input id="Cancel" src="Cancel.jpg" type="image" alt="cancel" height="30" width="73" />
-
This is ajax page -
function GetXmlHttpObject() {
-
var request;
-
try {
-
request=new XMLHttpRequest();
-
}
-
catch (e) {
-
try {
-
request=new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch (e) {
-
try {
-
request=new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
catch (e) {
-
alert("Your browser does not support AJAX!");
-
return false;
-
}
-
}
-
}
-
return request;
-
}
-
-
-
function pages(){
-
var FullName =document.getElementById('FullName').value;
-
-
}
-
-
1 2026
It would be probably better to use the form for places like this if there is going to be a bit of data.
This is one of my ajax functions.. - function displayMiningSelectDialog(astID)
-
{
-
miningDialogHttp = getXMLHttp();
-
if(miningDialogHttp == null)
-
{
-
alert ("Browser does not support HTTP Requests");
-
return;
-
}
-
var domain = document.domain;
-
var url="http://" + domain + "/GAME/PHP/Scan/ScanXMLhttp.php";
-
url=url+"?miningDialog=1&astID=" + astID + "&sid="+Math.random();
-
miningDialogHttp.open("GET",url,true);
-
miningDialogHttp.onreadystatechange=displayMiningSelectDialogResponse;
-
miningDialogHttp.send(null);
-
}
-
function displayMiningSelectDialogResponse()
-
{
-
if (miningDialogHttp.readyState==4 || miningDialogHttp.readyState=="complete")
-
{
-
eval(miningDialogHttp.responseText);
-
}
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mihir |
last post by:
Hi There,
I've problem while I submit a button where I used AJAX, I created
simple page which will search the customer name from database using
AJAX. Once I search customer ID i need to search order related to that
customers. So on my page I've Search Button(Image Button).. Now if I
click on search button without selecting the customer from the result
which I get from AJAX method then it will work fine but if I select a
customer ID from...
|
by: AECL_DEV |
last post by:
Hello Everyone,
Ive seen alot of people saying that the best way to AJAX Validate a form is
through the submit button, because validation should be synchronous. Im
wondering, is there any good way to validate a form field by field like AJAX
would do, but to keep it synchronous? i.e. one action, one validation.
Thanks,
|
by: Martin |
last post by:
Hello NG,
I've been doing some AJAX for a few weeks now. The basics worked fine so
far, but now I've got the following problem which I can't solve:
With AJAX you typically update/replace only parts of your page. But in
my application there are situation when I first notice on the server --
so AFTER sending an AJAX request -- that I have to update the complete
page instead of only some parts. And what do I do now???
|
by: John Chan |
last post by:
Hi,
Im doing a maintenance application in ajax and coldfusion at work on IE6
exclusively. I have a save button on each form and i have to do various
validations server side and on client side when the user clicks save i.e
check that user exists in table, check users password is the same as
password in table, check password is valid, check that logged in user is a
super user etc etc to get the correct error message. Different forms may or...
|
by: Sandman |
last post by:
So, I've used ajax for quite some time for different stuff. Mostly I
just feed a funktion I made with the ID of the DIV that should be
updated with the output from page XXX.php
Now I want to have a standard funktion to set a JS variabel to the
output of a page. I am doing a date validation thing, which is done in
PHP. So this is how far I've come so far:
function ajaxresults(url){
var ajax = createAjaxObject();
| |
by: lucyh3h |
last post by:
Hi,
I am trying to use XMLHttpRequest to do server side validation.
I have several fields on a form and a submit button. The submit button
has an event assocated with it when clicked. The javascript method
will do the form validation for each field one by one.
For each field, an XMLHttpRequst will be made to a PHP file and get
the return, either set an error field (<span>'s innerHTML) or leave it
empty.
Then I'll check the error field...
|
by: ak1dnar |
last post by:
Hi, I got this scripts from this URL
There is Error when i submit the form.
Line: 54
Error: 'document.getElementbyID(....)' is null or not an object
What is this error.
Complete Files
|
by: rizwan6feb |
last post by:
Hi experts! Recently i was working on "Form Validation Using Ajax". My form validation was creating problem, when a user changes focus too quickly. I had a post related to this, but was unable to solve the problem. Here is the previous post
http://bytes.com/forum/thread798289.html
Trying to trace the problem I have written a code (Separate from The Form Validation) which sends 300 requests with an interval of 10 miliseconds and displays the...
|
by: ashwinkumar18 |
last post by:
hi,
am very new to ajax and js . i tried using ajax for server validation in my jsp. i also used js for client side validation
i have my js script for client side validation in a seperate file. i embedded the ajax code in the jsp itself.
the client side validation and the ajax code are working when i use them seperately.
but when i try to use them both , the client side validation is not taking place at all. my page is directly...
|
by: pradeepjain |
last post by:
hii guys ,
I wanna share a very gud ajax validation script with php...
Ajax Form Validation - sForm | chains.ch weblog
I am very new to ajax .So i wanna small help....i want to improve that script with adding checkbox,radiobutton validation and dropdown list validation . but i am not able to do it.....any one can add his/her code into that ajax script..tht i can have a look at it..
And i have found a small bug in tht script...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |