pappakaka Posted February 11, 2011 Share Posted February 11, 2011 How do i turn this: public function show_errors() { foreach($this->errors as $key=>$value) echo $value; } ..into something that sends the $value to a class or a specific element in my HTML document? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 11, 2011 Share Posted February 11, 2011 Where is your HTML document? This is a very vague question. Quote Link to comment Share on other sites More sharing options...
pappakaka Posted February 11, 2011 Author Share Posted February 11, 2011 Where is your HTML document? This is a very vague question. The code in my previous post is in a file named class.register.php and i want it to send the $value (witch holds the error messages if you typed something wrong for example) to a class in my HTML file witch is located in "../register.php". Don't know if it's even possible but i think it should be? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 12, 2011 Share Posted February 12, 2011 You can use sessions to make variables pass from one file to another. If you're including the html file (that is actually a php file, it ends it .php), AFAIK the scope should allow you to access it anyway. PS: Look at Smarty, it's really good for doing php+html. Quote Link to comment Share on other sites More sharing options...
pappakaka Posted February 12, 2011 Author Share Posted February 12, 2011 Ok i really need help with this question. I have 1 file with the HTML form (register.php). And 1 file with PHP code to handle the HTML form upon registration (class.register.php). When you register and for example enters "emailaddress.com" instead of "email@address.com". class.register.php creates an error message saying something like "Please enter a valid email address". If i have this HTML code in my register.php file: <div class="messages"></div> And i want to send the error message "Please enter a valid email address" to my div class (<div class="messages"></div>). How could i do that, would be great with an example? To make the long story short: I want something in my HTML file to show the errors that the PHP file makes and not the PHP file. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 12, 2011 Share Posted February 12, 2011 You'll need to post some code showing the form, and how the errors are returned. Quote Link to comment Share on other sites More sharing options...
pappakaka Posted February 12, 2011 Author Share Posted February 12, 2011 I don't mean anyting specific, just want too know a way too do it. Here's an example: public function show_errors() { foreach($this->errors as $key=>$value) SEND $vaule TO (register.php) class="messages" <----- something like that? } public function valid_data() { if (empty($this->username)){ $this->errors[] = 'You must enter a username!'; } } And then the HTML form would look something like this: <div class="messages">You must enter a username!</div> And in CSS i would have already set the position, width, height, color etc. of the div element. I know you can't type SEND $value TO and stuff like that, but just to show more what i mean if it makes sense? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 12, 2011 Share Posted February 12, 2011 This question has been asked several times the past few days. Was it you? Quote Link to comment Share on other sites More sharing options...
pappakaka Posted February 12, 2011 Author Share Posted February 12, 2011 Yes, i posted a similar question yesterday but it seems to be a hard problem to solve cause i couldn't get an answer or i'm not explaining it clearly enough! Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 12, 2011 Share Posted February 12, 2011 Yes, i posted a similar question yesterday but it seems to be a hard problem to solve cause i couldn't get an answer or i'm not explaining it clearly enough! Don't make a new post for the same question. For the second time, that's not an HTML file if it ends in .php. It's still a php file. I told you once to look at using Sessions, and also to look at Smarty, but that might be too complicated. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 12, 2011 Share Posted February 12, 2011 Please keep the same problem to one thread. Threads merged. Quote Link to comment Share on other sites More sharing options...
pappakaka Posted February 12, 2011 Author Share Posted February 12, 2011 Yes, i posted a similar question yesterday but it seems to be a hard problem to solve cause i couldn't get an answer or i'm not explaining it clearly enough! Don't make a new post for the same question. For the second time, that's not an HTML file if it ends in .php. It's still a php file. I told you once to look at using Sessions, and also to look at Smarty, but that might be too complicated. Oh i must have missed you previous post! But thank you, i will start looking into sessions and smarty! Quote Link to comment 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.