Webmaster Forums 101 - Free Help and Discussions
 
 
 

MEMBER REWARDS - Earn free advertising by participating in these forums! Click here for details.

Welcome to Webmaster Forums 101!

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Reply
 
Thread Tools Search this Thread Display Modes
Old 23rd February 2005, 07:38 AM   #1
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default custom fields in form using mysql

Hi there everyone im having some problems with doing costum fields in my form using mysql.

I can display the fields just fine the problem im having is with the authentication of the fields to see if there empty or not

My code is too long to post in here so heres a link to it

http://www.hintondesign.org/form_auth.phps

The part im having problems with is grabbing the info from the database and putting it into an array and then putting that stuff from the array into an if statment to do my error checking.
Thanks

Any help would be apperetiated.

ps. i love the new forums by the way.
Viper
__________________

Last edited by viper : 23rd February 2005 at 07:42 AM.
viper is offline   Reply With Quote
Old 23rd February 2005, 08:03 AM   #2
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Welcome back viper, long time no see

From what I read, you want something like this. You'll jsut need, to convert it into your style of coding:

PHP Code:
$login_check mysql_query("select * from users where username='$username' and password='$password'") or die("<b>MySQL Error:</b> " mysql_error());
$affected_rows mysql_num_rows($login_check);

if(
$affected_rows == 1) {
// Set cookie/session and show whatever
} else {
print 
"Error: Invalid Username and/or Password";


That will basically check if the username and password exists. So even if the fields blank it will give them an error.

Hoep that help
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 23rd February 2005, 08:20 AM   #3
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default

Hi ben ya it has been awhile since ive been here looks like it's starting to pick up again here.

Your way won't work for me it's hard to explain what i need lol

What i'm trying to do is have a form where the user can add or delete his own fields in the form im having no probs with that all the field info is held in a mysql database and im having probs taking the info from the database and putting it in a if statment if the field is required in the database.

for example normally youd do

if(!$HTTP_POST_VARS[fieldname]) or if(empty($HTTP_POST_VARS[fieldname])) to check if those fields are empty or not but since i grab my field info from the database doing that won't work cause the fieldnames will change if the user changes it in the database. I can't get that way of error handling to work properly.

I hope im explaining this good lol it's not easy to explain.
Thanks

Viper
__________________
viper is offline   Reply With Quote
Old 23rd February 2005, 08:41 AM   #4
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

OK, so basically you want to check if a field in the database is empty for a certain user?

If so, perhaps this is what you're looking for:

PHP Code:
$check_fields mysql_query("select fieldname from users where username='$username' and password='$password'") or die("<b>MySQL Error:</b> " mysql_error());
$row mysql_fetch_array($check_fields);

 if(isset(
$row[fieldname])) {
// Yay, it's not empty!!!
} else {
print 
"Error: The field is empty...";



Is that what you're looking for?
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 23rd February 2005, 08:57 AM   #5
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default

not really have you ever used esupport the support ticket system well you know in the submit ticket form they have the default fields that never change and they have a special part at the bottom for custom form fields that the admin can add or delete in the admin area. So what im trying to do is check if those custom fields in the form the required ones are empty or not. And all the info for those custom form fields for example <input type="text" name="name" id="name" value=""> i have the type name and id inputed into the database the values of those anyway. so i need to grab those values out of the database manly the name part to use $HTTP_POST_VARS in and if to see if those form fields are empty.

Thanks

Viper
__________________
viper is offline   Reply With Quote
Old 23rd February 2005, 09:09 AM   #6
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

OK... let me think...

So basically you want to check if the fields in the form (E.g: <input type="text" name="customfield1">) is not empty after they submit the form? And if it is, it displays an error?

Is that correct?
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 23rd February 2005, 09:12 AM   #7
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default

yep that's what i need but im having troubles doing that when the field information is in a database can't get the error checking to work.

Thanks for the help

Viper
__________________
viper is offline   Reply With Quote
Old 23rd February 2005, 09:20 AM   #8
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

It might be best if you don't use the database to check. Let's say this is your form:

HTML Code:
<form action="check.php" mehtod="post"> Custom 1: <input type="text" name="field1"><br> Custom 2: <input type="text" name="field2"><br> <input type="submit" value="Submit">

Then you could sue this PHP to check if they are empty:

PHP Code:
if(isset($_POST['field1']) && isset($_POST['field2'])) {
echo 
"they aren't empty, please proceed";
} else {
echo 
"they are empty!!!!!! Go back!";


Hope thats what you need
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 23rd February 2005, 10:22 AM   #9
Peter Sinclair's Avatar

Username: Peter Sinclair
Rank: Super Moderator
Join Date: Jan 2005
Location: Australia
Posts: 282
Points: 14.18
Default

Yep, from what I';ve read, that's what he's trying to do.
__________________
Peter Sinclair
http://www.motivationalmemo.com/
Motivational author and speaker, has created many powerful motivational tools that have been designed to empower your life. Thousands have already benefited from his books and ezines. And as Peter says, "When life requests an answer, shout 'YES!'"

Australia Website Designers
Peter Sinclair is offline   Reply With Quote
Old 25th February 2005, 09:38 AM   #10
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default

Hi guys ya you have the right idea of what i want but i wanted the custom fields to be dynamic so when the user adds the field from the admin section of my script it will automatically add the field to the form and the validation if it's required so the user of the script doesn't have to edit code or add code at all. That's why i was using mysql to store the field info. Didin't think it was so hard to get dynamic validation to work though lol.

Thanks for the help guys i always liked this place. This is one of the places were i learned php so good wit hyour guys help.

Viper
__________________
viper is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
form mail jonDapron Server-Side Scripting & Databases 1 4th October 2003 11:41 AM
Form - hidden fields - autorespond - reply email Anonymous Website Design & Coding 1 21st June 2003 05:39 PM
FORM HELP Anonymous Server-Side Scripting & Databases 21 9th April 2003 12:46 AM
form trouble Anonymous Server-Side Scripting & Databases 1 10th March 2003 06:05 PM

Login
User Name
Password


Featured Members


Featured Links


Useful Resources
Webmaster Resources
Developers Tools
Developer Tutorials


Partners

All times are GMT +10. The time now is 07:35 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.3.2
 
 
WEBMASTER FORUMS 101
ARCHIVE
CONTACT US
TOP
   
© Webmaster Forums 101 2005. All Rights Reserved.
Design by: vBCore