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? 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.