FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » Pop window loads link # and store it in variable
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Pop window loads link # and store it in variable [message #22486] Fri, 04 February 2005 14:49 Go to next message
brunces is currently offline  brunces   Brazil
Messages: 1
Registered: February 2005
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Friends,

Hello, how are you? I'm a beginner in web designing and am not finding a solution for this problem I have, but I'm sure it must be very simple for you experts.

I'm creating this website, a kind of BLOG for my pupils (I'm a teacher). There will be lots of downloadable files related to the classes already given. I tried to create it using an ordinary blogger website, but the web space provided on most of these bloggers is very small and, in intention to avoid "mirroring" for those files, I prefered to create my own site (blogger) and host it in one single server (which provides large web space), instead of using ordinary bloggers.

Another reason why I've chosen to do that is the option "Comments" provided by bloggers. Most of them allows visitors to type their comments and, after clicking the SEND button, their messages are automatically posted. To protect the site against misuse, I intend to do the following...

Visitors type their comments. These messages are sent to my email and, after analysis of their contents, I myself post their messages. That's it. So, here's my doubt...

Example:

(It's sort like the operation scheme of the foruns.)

I've got several posts in one page. Each post has 2 links by default: Comments (visitors click and send their own comments to my email) and Send to friend (visitors send the www address and the number of the post to a friend's email). If I learn how to create one, obviously I learn how to create both, therefore I'm gonna talk about the link "Comments" only.

http://blogparatestes.bigblogger.com.br/

This is a web blogger which I created to "study" its source code.

-----
This site is in Portuguese, for I am Brazilian. Here are some translations:

para = for
testes = tests
comentários = comments
enviar para um amigo = send to friend
enviar formulário = send form
nome = name
meu = my
-----

I found out that when clicking the link "Comentários", a JavaScript code sends the number of the post (id_post) to a page called "comentarios.php".

Here's the code...

<a href="java script:func_janela('comentario','/comentarios.php?id_post=3E059059063076129',400,350);">Comentários (0)</a>



This page is opened in a new window. It has a form. The number of the post (id_post) is automatically loaded inside one of the lines of the form (obviously, to be sent to my email with the data filled in the form).

Here's the line...


<input type="hidden" name="id_post" value="3E059059063076129">



After clicking on the "Enviar formulário" button, a PHP code captures the data from each INPUT of the FORM and send them to my email. I've already made a draft for this code by myself.

Here's my draft for the code...


<?php

$id_post = $_GET["id_post"];
$nome = $_GET["nome"];
$mail = $_GET["mail"];
$msgm = $_GET["msgm"];

mail("meuemail(at)email(dot)com","Fale conosco","ID Post: $id_post <br> Nome: $nome <br> Email: $mail <br> Comentário: $msgm","From: $ed_email\nContent-Type: text/html; charset=us-ascii");

?>


I'm not sure if this is the right way to make it, but in other tests I've made, it worked out.

Now what I want to know is...

How is the structure of the code which makes that [input type="hidden" name="id_post" value=""] receives the value from the number of the clicked post (id_post)? Is there any specific code just for that? How is it like? Where is it located? Inside the "comentarios.php" file itself?

Another doubt... The parameter ACTION of the FORM calls the page itself, I mean, it calls a PHP code which is located inside the "comentarios.php" file itself. How is this code like? (The code above, which I've made a draft, I've tested it in a separated file, that's why I said it worked out.) How do I put all these PHP codes in the same file?

Well, that's it! Sorry for the long text. If someone has pacience, time and a good heart to explain that to me with a few examples, I will really appreciate that. Really, really!

I've searched in some PHP tutorials pages, but as I don't know much about PHP language, I couldn't find exactly what I need.

I accept any easier suggestions (as another language - ASP, Java, whatever), if possible.

Thank you all very much for your atention.

Hugz.

Bruno

--------------------

(A friend of mine asked some things and this was my answer to him.)

Hi, buddy.

"where is this 3E059059063076129 comming from? you need to make this number into a variable."

I think it comes from the link. (...php?id_post=3E059...) But maybe I'm wrong.

<a href="java script:func_janela('comentario','/comentarios.php?id_post=3E059059063076129',400,350);">Comentários (0)</a>


I myself will type this code for each link. That will be simple. Every time I post a message, I'll create a new link (copy and paste) for it and put the number of the message in it. The number is simple, it's the date and the time of the post. Example:

Post: 02/04/2005 - 07:55 AM
id_post: 20050204-0755AM

So, I type it by myself for each link.

The point is how to transfer that number from the clicked link into a HTML FORM tag (on the new opened page)?

"are these blogs stored in a db? can i see more code?"

No, they're not! Ordinary bloggers are certainly based on DB, but in my case, I won't do that. I don't know how to deal with DB for web. So, I'm gonna create a HTML page and put the posts in it. Each HTML file will have 10 posts. The comments will be posted below its related post.

-----

In other words, what I want to do is...

- There are several posts in my page. Each one has its specific links for "Comments" and "Send to friend";
- Someone reads the posts and choose one to send his comments, for example. When he clicks the link, a new page is opened. This new page has a form (Name, Email, Message);
- The guy fills the form and click on "Send form";
- Each INPUT of the form is sent to my email PLUS the number of the related post.

So, here's the point... I want to bring that number of the post to a hidden input tag of the form, so that it will be sent to my email with the other inputs when someone clicks "Send form".

That's it. So...

1st) I don't know how to capture that number of the clicked post and put it inside the hidden input tag of the form.

2nd) I used to create a separated PHP file to put the codes (which send the inputs of the form to my email) and a single frase like: "Your message has been sent successfully!". But it seems theres no need for it. These codes and frase can be put in the same file (the file of the form itself), and this is the other thing I don't know how to do.

It seems the form page has both PHP codes: one to capture the id_post and to put it inside that hidden tag and other to send the inputs of the form to my email. This is what I don't understand how to do in the same file.

That's it.

Maybe you guys have other easier ways to do the same thing. Every suggestions are welcome, OK?

Thorpe, thank you very much for your attention.

Hugs.

Bruno
Re: Pop window loads link # and store it in variable [message #22489 is a reply to message #22486] Fri, 04 February 2005 15:51 Go to previous message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
http://www.wordpress.org/
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: how do I create a redirect in a php file
Next Topic: Ò»¸öSQLITEÊý¾ÝÀà
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Dec 18 15:11:15 EST 2017

Total time taken to generate the page: 0.00679 seconds