hi ,
A strange error is coming , when i run a php file , all the php and java script executes before submit only which actually should execute after clicking on submit button and performing some checks.what to do ?
5 1992
Hi, please explain your problem a little more.
I have written a file , in which i am creating a form to create new user .On submit i am checking for duplicate username in database and if username already existing i come back to form and if does't exist then accepting user name create a new user.
But the problem is that as soon as i acces url what ever php i have written is getting executed before displaying form objects . And because the form are empty fist time , there is no data fir queries , mysqo_numrows() is throwing warning before only.
how to rectify it ?
Atli 5,058
Expert 4TB
Hi.
We would need to see the part of the code that is causing the problem to be able to say anything for sure.
But I will say this.
PHP is a server side language. IT will ALWAYS be executed before the HTML reaches the browser. You can not execute PHP code using JavaScript events or any other client-side coding. (Except AJAX, but that is an entire different thing.)
here "user doesnot exist shoud appear on if i ma getting action=dup but its getting executed before only..... -
<?php
-
include("conn.php");
-
if($_REQUEST["action"] == "add");
-
{
-
$username = $_GET["username"];
-
$passward = $_REQUEST["pass"];
-
$fname = $_REQUEST["fname"];
-
$lname = $_REQUEST["lname"];
-
$teleno = $_REQUEST["tele"];
-
$email = $_REQUEST["email"];
-
$company = $_REQUEST["company"];
-
$add = $_REQUEST["add"];
-
$country = $_REQUEST["add"];
-
$city = $_REQUEST["add"];
-
$occu = $_REQUEST["occu"];
-
$membership = $_REQUEST["membership"];
-
$q = "select u_name from my_user where u_name ='".$username."'";
-
-
if(!mysql_query($q))
-
{
-
die("error".mysql_error());
-
}
-
$r = mysql_query($q);
-
$rows = mysql_numrows($r);
-
if($rows <= 0)
-
{
-
$query = "insert into my_user values('','$username' , '$passward', '$fname' , '$lname' , '$tele' ,'$add','$city','$country','$occu','$company','$membership',CURDATE(),'$email')";
-
if(!mysql_query($query))
-
{
-
-
die("error".mysql_error());
-
}
-
$to = $email;
-
$subject = "Your Registration At Classifieds Guide India";
-
$message = "Dear ".$fname;
-
$message .= "\n\tThankyou For Registring In Classifieds .You will shortly receive a confirmation call to get to know about payment details at your give telephone number :".$tele.".Plese be ready with details.\n\t\tThankyou\nClassifieds .";
-
$from = "xyz@yahoo.com";
-
$headers = "From: $from";
-
mail($to,$subject,$message,$headers);
-
header("Location:create_user.php");
-
}
-
if($rows > 0 )
-
{
-
-
header("Location:create_user.php?action=dup");
-
}
-
}
-
?>
-
Atli 5,058
Expert 4TB
Line #65 of the first code. There is an extra semi-colon after the if statement, before the code block, which means the code block will always get executed regardless of how the if statement was executed.
You should also consider changing the form method to POST.
Sending all that data on the GET protocol is just not sanitary :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ratlhead |
last post by:
Hey all,
I'm attempting to do some form processing on a server that has
register_globals off, however, I've run into a confusing situation and
need some help.
Basically, the form is a...
|
by: Shannon |
last post by:
Hi everyone,
I am trying to post some data to a form using the XMLHTTP object, and have run into a problem trying to find the proper
location of the receiving page.
The form points to a...
|
by: Charles Banas |
last post by:
weird subject - i hope more than just one curious regular will hear me out.
:)
ok, i've got a bit of a big problem, and i need answers as soon as
possible.
i know this forum is meant for web...
|
by: Pete |
last post by:
I have form/select which executes a function using onchange. No
problem. However, when I validate the page with a strict HTML 4.01
doctype at http://validator.w3.org, it demands either an action or...
|
by: Mic |
last post by:
Goal: delay execution of form submit
Code (Javascript + JScript ASP):
<%
Response.Write("<OBJECT ID='IntraLaunch' STYLE='display : none'
WIDTH=0 HEIGHT=0...
|
by: Steve Benson |
last post by:
Our regular programmer moved on. I'm almost clueless in Javascript/ASP and
got the job of adapting existing code. In the page below, everything works
until I added the function checkIt() to...
|
by: adawson |
last post by:
Hi,
I need to execute some code when form submission is stopped before the
page is returned from the server. For example, a user clicks a button
to submit the form, realizes they've made a...
|
by: rpjd |
last post by:
I am trying to submit entries in a form to a database. I am using
"
within my submission form and
$_POST
I am getting the connection to the database but I my script is not executing,...
|
by: Megalog |
last post by:
Hey guys.. my turn to ask a question:
I'm having a weird issue with a form I've reworked. This form has a combo box, which when used is changing the recordsource of a subform. This subform has...
|
by: dancerman |
last post by:
I want a simple as possible regex to check the format of my form submission URL string, I don't care whether is an actual real working URL, just that it be in proper URL format and, IF POSSIBLE add...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |