gork4life Posted December 26, 2011 Share Posted December 26, 2011 Can I include a class file in the same page that I use an instance of the same class with my action attribute with my form. Here's the code <?php include 'Resources/User.php';?> <html> <head> <title></title> <link href="stylesheets/styles.css" rel="stylesheet" type="text/css"/> </head> <body> <form action = "Resources/testClass.php" method="post" enctype="multipart/form-data"> <label>First Name: </label> <input type="text" name="fname" id="fname" size="25" maxlength="25"/> <label>Last Name: </label> <input type="text" name="lname" id="lname" size="25" maxlength="25"/> <label>Email: </label> <input type="text" name="email" id="email" size="25" maxlength="40"/> <label>Username: </label> <input type="text" name="username" id="username" size="25" maxlength="32"/> <label>Password: </label> <input type="password" name="password" id="password" size="25" maxlength="32"/> <label>Re-enter Password: </label> <input type="password" name="conf_pass" id="conf_pass" size="25" maxlength="32"/> <br /><br /> <input type="submit" name="submit" id="submit" value="Register"/> <input type="reset" name="reset" id="reset" value="Reset"/> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/ Share on other sites More sharing options...
trq Posted December 26, 2011 Share Posted December 26, 2011 Of course you can, why not try it? Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/#findComment-1301446 Share on other sites More sharing options...
gork4life Posted December 27, 2011 Author Share Posted December 27, 2011 I'm sorry I didn't explain my problem fully. If I add the include I get this error. Warning: include(../includes/Constants.php) [function.include]: failed to open stream: No such file or directory in /var/www/ggender/Resources/User.php on line 1 If I exclude the include and just live the action attribute with the instance of the same class I have no problem and it works as intended. Basically what I'm trying to do is use the instance to process the form, and include the class so that I can use a property with in that class. Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/#findComment-1301492 Share on other sites More sharing options...
trq Posted December 27, 2011 Share Posted December 27, 2011 That error means php cannot find the file to include. Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/#findComment-1301497 Share on other sites More sharing options...
gork4life Posted December 27, 2011 Author Share Posted December 27, 2011 Well the think is that with out my including the class in that file. I'm including a different file to the database and it works so I'm not really understanding why I"m getting this error. Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/#findComment-1301499 Share on other sites More sharing options...
scootstah Posted December 27, 2011 Share Posted December 27, 2011 You're getting the error because the file you are trying to include doesn't exist. Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/#findComment-1301501 Share on other sites More sharing options...
gork4life Posted December 27, 2011 Author Share Posted December 27, 2011 The file exists because I'm using an instance of the same class to process my form. And when I exclude the include function everything works as it should. Which is insert the form data into my database. Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/#findComment-1301502 Share on other sites More sharing options...
trq Posted December 27, 2011 Share Posted December 27, 2011 The file might exist, but not where your telling php it is. Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/#findComment-1301503 Share on other sites More sharing options...
scootstah Posted December 27, 2011 Share Posted December 27, 2011 Then why not leave the include out and call it a day? Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/#findComment-1301513 Share on other sites More sharing options...
gork4life Posted December 27, 2011 Author Share Posted December 27, 2011 I figured it out. I added ../ in one of my files. Thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/253854-include-file/#findComment-1301525 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.