PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
skylers
Forum Newbie
Posts: 2 Joined: Fri Feb 17, 2012 12:48 pm
Post
by skylers » Fri Feb 17, 2012 12:52 pm
Hi-
I'm fairly new to php specifically and I'm having a problem referencing object functions. My html has this:
Then my form has this:
Code: Select all
<form name='loginForm' method='post' action='<? $db->login(); ?>' onSubmit='validateForm();'>
And my DB object looks generally like this:
Code: Select all
<?php
Class DB {
private $dbUsername;
private $dbPassword;
private $dbServer;
function login() {
[do db interactions]
}
}
When I run all this, the content where my form is and anything after doesn't show up at all on the page. Whats wrong? I really appreciate the help!
xtiano77
Forum Commoner
Posts: 72 Joined: Tue Sep 22, 2009 10:53 am
Location: Texas
Post
by xtiano77 » Fri Feb 17, 2012 2:08 pm
The action property of the form tag needs the name or target file that is going to process the form submission. You can leave the code the way it is as long as the method returns the name of the target script that will process the form.
skylers
Forum Newbie
Posts: 2 Joined: Fri Feb 17, 2012 12:48 pm
Post
by skylers » Fri Feb 17, 2012 2:15 pm
How would that look?
Code: Select all
<form method='post' action='../path/to/file/DB.php<? $db->login() ?>'>
or am I way off base there?
or are you talking about at the end of my javascript validation? Or do I need a helper method in this file that redirects to the actual DB.php file?
Thanks again for your reply!
Sky
xtiano77
Forum Commoner
Posts: 72 Joined: Tue Sep 22, 2009 10:53 am
Location: Texas
Post
by xtiano77 » Sun Feb 19, 2012 7:21 pm
Your HTML form:
<form method='post' action='../path/to/file/DB.php' onSubmit='validateForm( );'>
Your action file (“DB.php”):
Code: Select all
<?php
// your code here...
$db = new DB( );
$db -> login( );
// your code here...
?>