/    Sign up×
Community /Pin to ProfileBookmark

PHP Form Error. HELP!

Okay my form is in an html file. here is the form part.

[code]
<form action=”WellnessSubmit.php” method=”post”>
[/code]

the php file…

[code]
<?php

require(“config.php”);

if($_GET[‘action’] == ‘post’)
{
if($_POST[’employeeid’] == ” || $_POST[‘date’] == ” || $_POST[‘activity’] == ” || $_POST[‘miles’] == ”)
{
//if everything is not filled in than prints out error message
echo error(“blank”);
exit;
}

$conn->Execute(“INSERT INTO Activity_Log
(Employee ID, Date, Activity, Miles) VALUES(‘$_employeeid’, ‘$_date’, ‘$_activity’, ‘$_miles’) “)
or die(ADODB_error());
}

function error($error)
{
//if error is equal to blank
if($error == ‘blank’)
{
echo “<b>Please fill in all the required fields before submitting</b>”;
}
}
?>[/code]

config php file

[code]<?php
$db_conn = new COM(“ADODB.Connection”);
$connstr = “DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=”. realpath(“./Copy of HR Employee Wellness Program.mdb”).”;”;
$db_conn->open($connstr);

?>[/code]

Now here is the continuous error i get when i try to submit

[code]Notice: Undefined index: action in F:InetPubwwwrootEmployeeWellnessProgramWellnessSubmit.php on line 5[/code]

?
I have not the slightest clue as to why i’m getting this error. Any suggestions would be greatly appreciated!! I have to have this done by the time i leave work tonight? in about 3.5 hours or so

to post a comment
PHP

13 Comments(s)

Copy linkTweet thisAlerts:
@dtm32236Oct 24.2007 — "PHP Form Error. HELP!"

you're better off ASKING for help, not demanding it.... and using the word 'help' in the subject of your post is frowned upon, especially when in ALL CAPS. 'Please help' may have sound a little better...

anyway, i don't know PHP, but good luck.
Copy linkTweet thisAlerts:
@bCourtney07authorOct 24.2007 — Okay so I know not to come back to this forum, thanks alot for nothing.

I appologize for my thread title. I didn't intend for it to sound like I was [I]demanding[/I] help.

I don't like being scrutinized when I'm not the only one with "Help" in the title.
Copy linkTweet thisAlerts:
@ryanbutlerOct 24.2007 — I haven't the slightest clue why you're using MS Access with PHP, but by default, when working with ASP.NET and MS Access you have to give the ASPNET client write permissions to the database. It looks like you have a write permission problem, either there or in IIS.

Also, try adding tick marks to each field name in your SQL query as well:

[CODE]INSERT INTO table(column1,column2)VALUES('$colvalue1','$colvalue2')[/CODE]
Copy linkTweet thisAlerts:
@dtm32236Oct 24.2007 — hey bCourtney07

i wasn't trying to be a jerk about it - just some advice for future posts...

Ryan Butler is pretty good with this stuff, and he should be able to help you out with your problem.

Good luck with it.
Copy linkTweet thisAlerts:
@bCourtney07authorOct 24.2007 — I appologize dtm32236. I've got people on my tail to get this done. Every 5-10 minutes somebody is asking if it's done yet. It's just frustrating, especially since they just gave this to me at the end of the day yesterday plus all of the other projects i have to do by friday.. ? sorry

I put in the tick marks and i still get the same error ? I'd much rather use MySQL instead but the database was created in Access (not by me either!!) The database is on the server with permissions to everyone also
Copy linkTweet thisAlerts:
@dtm32236Oct 24.2007 — that's terrible... i don't blame you for being frustrated.

i wish i could help you out, but like i said, PHP is not my thing.

i'm also a little on edge - it was a late night and i'm awfully hung over ? ... but i guess that's my fault. work is terrible today (that's why i've spent most of my day on these forums - mostly being an ass to other people). I probably have a few other people i owe apologies to.

anyway, good luck with this... hopefully someone will be able to help you out.
Copy linkTweet thisAlerts:
@ryanbutlerOct 24.2007 — What's line 5 look like? Usually, in PHP you back track from there. Your code is oddly structured.

I've never done PHP like this before. If no one helps you here...you might also try:

http://www.phpfreaks.com

They answered a truly baffling question for me about a week ago.
Copy linkTweet thisAlerts:
@bCourtney07authorOct 24.2007 — well here is lines 1-6
<i>
</i>&lt;?php

require("config.php");

if($_GET['action'] == 'post')
{


and here is the config file

<i>
</i>&lt;?php
$db_conn = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("./Copy of HR Employee Wellness Program.mdb").";";
$db_conn-&gt;open($connstr);
?&gt;


I do greatly appreciate your help and I'll try phpfreaks too.
Copy linkTweet thisAlerts:
@ryanbutlerOct 24.2007 — Ah, I believe the error message is stating that you're not grabbing anything from the address bar. When you use $_GET, you need to grab an action from the URL, such as:

http://www.domain.com/myform.php?by=L

Then in PHP:

[code=php]<?php
if($_GET['by']=="L"){
//-do stuff here
}
?>[/code]


Try appending this onto the opening <form> tag:

[CODE]<form action="WellnessSubmit.php?action=post">[/CODE]

And switch out the method to get.

Or, switch out the $_GET for:

[code=php]if(isset($_POST['submit'])){

}

[/code]
Where submit is the name of the submit button and switch the form method to post. You'd be better off using $_POST.
Copy linkTweet thisAlerts:
@bCourtney07authorOct 24.2007 — Well i got the index error fixed..just had to change

This:

[code<form action="WellnessSubmit.php" method="post">[/code]

to this:<i>
</i>&lt;form action="WellnessSubmit.php?action=post" method="post"&gt;


but now i get this error

<i>
</i>Fatal error: Call to a member function on a non-object in F:InetPubwwwrootEmployeeWellnessProgramWellnessSubmit.php on line 15
Copy linkTweet thisAlerts:
@ryanbutlerOct 24.2007 — What's that line # look like?
Copy linkTweet thisAlerts:
@bCourtney07authorOct 24.2007 —  $db_conn-&gt;Execute("INSERT INTO Activity_Log
Copy linkTweet thisAlerts:
@ryanbutlerOct 24.2007 — Hmmm...don't know on this one. Some thoughts:

[LIST]
  • [*]Are you auto-incrementing the employee ID? If so, you don't need to pass that in as a parameter

  • [*]Is there another function that Execute needs or another parameter that its expecting?

  • [/LIST]


    Other than that...it's hard to tell.
    ×

    Success!

    Help @bCourtney07 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.16,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...