473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How do I make that if the form is empty, it cannot submit?

moishy
104 100+
Hi! I'm making an order form where the customers fill out the desired quantity, and the form is emailed to me.
But they also must fill out their contact info.

So How do I make it, that if they havn't filled out fields A, B, or C - the page will just refresh, and not Submit.


Thanks in advance folks.
Oct 5 '06 #1
4 1805
mainul
51
Hey you can try this code.


<?php if(empty($_POST['A'] ||$_POST['B'] ||$_POST['C'])){ // names from the form feild
print 'error go back';
// if you want to go back to the orignal form with messages like that i would use a session or hidden feilds to pass back the orignal data sent and the error message to print
}else{
//sendl script or whatever you need to do
}
?>
Oct 5 '06 #2
moishy
104 100+
Hey you can try this code.
Yeah, I tryed it but the error is:
Parse error: syntax error, unexpected T_BOOLEAN_OR, expecting ')'

Any help?
Oct 5 '06 #3
bevort
53
Use Javascript or VB script
First start with a disabled button.
Then, with the onChange() event remove the disabled status if a user chahges the content of a field.
Do not forget to check with the onSubmit() event if at least one field has some content

A standard rule should be to do on the client side what can be done there instead of doing it on the server
Oct 5 '06 #4
ronverdonk
4,258 Expert 4TB
A standard rule should be to do on the client side what can be done there instead of doing it on the server
Where is that rule written?
What about security issues on a client?
What if JavaScript is disabled on the client?

Ronald :cool:
Oct 5 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: T.E. | last post by:
Hi all, I'm a newbie in php. I encounter a problem with php form that has only one textfield. If I click on the submit button, the form works fine. However, when I press 'enter', the form...
5
by: lsarg | last post by:
i've been trying forever to figure out a way to use a regular text link in place of a submit button at the bottom of this. can't get it. i'm just starting to learn php, so i'm stuck. any help at...
4
by: Christoph Weber | last post by:
Hello, I have the problem that I want to submit a form only if the submit button is clicked with the mouse. The form should not be submitted if the user hits the RETURN key. Any suggenstions? ...
5
by: Batezz | last post by:
I have created a form (below) How do I stop it redirecting to another page (productsearchresults.php) when form is submitted if both the fields are blank? Any help appreciated. Batezz
1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
5
by: Joe Blow | last post by:
I'm sure I'm missing something blindingly obvious here. I am relatively new to PHP, so excuse dumb mistakes. I a trying to check a form submitted from an earlier page, and check $_POST for empty...
8
by: 2L | last post by:
Trying to write some code and this is just shitting me now! Bit of form validation stuff.... Variable is declared as follows..... --snip-- <script language="JavaScript"> <!---
2
by: Tim Mills | last post by:
The following code asks the user to sumbit a name, email address, and some text for a quotation via a FORM. I have written a javascript function to evaluate the fields in the form and pop-up a...
1
by: morangi | last post by:
<?php session_start(); error_reporting(E_ERROR && ~E_NOTICE && ~E_WARNING); ob_start(); $link = mysql_connect('localhost', 'root', 'test'); if (!$link) { die('Could not connect: ' ....
3
by: KOFI QUANSAH | last post by:
Hello, 1) I have a php script A with several buttons(not submit) on a form. 2) On click of any of the buttons, a specific javascript function is called. 3) Depending on the outcome of...
0
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...
0
isladogs
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...
1
isladogs
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...
0
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...
0
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...
1
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.