Jump to content

How do i send $value to a class in my HTML doc?


pappakaka

Recommended Posts

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? 

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.

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 protected]". 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.

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?

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.

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! :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.