10 Replies - 1228 Views - Last Post: 13 April 2012 - 09:16 AM Rate Topic: -----

#1 prefix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-April 12

Posting a topic on a website?

Posted 13 April 2012 - 07:05 AM

Hello there. I am trying to post a new topic on a website. I am kinda new to PHP, which means I am a bit stuck.


What I have so far:

<?php
if (isset($_POST['Submit']))
{
$display_name = $_POST["Display_Name"];
$option = $_POST["Option"];
}



I have been advised to use cURL in order to do this, so I am wondering how would I go about doing that?
Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Posting a topic on a website?

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,238
  • Joined: 08-June 10

Re: Posting a topic on a website?

Posted 13 April 2012 - 07:25 AM

what do you understand by "post a topic"? if it’s just getting a value from a POSTed form, you would have to echo out the contents from the $_POST array, but that is not persistent (for that you would have to save the data somewhere).

additionally (regarding your code), some versions of IE do not send the submit button’s value. i.e. your condition would fail even if the form is submitted. generally a better way is to test each form data item before you use it (related to "Feature Detection").

ex. (this may look complicated, but it includes security measures against XSS attacks and a sensible error handling)
// just a name, strip potentially malicious code
$name = filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING);

// Options, only numbers from 0 .. 5
$option = filter_input(INPUT_POST, "option", FILTER_VALIDATE_INT, array("options" => array("min_range" => 0, "max_range" => 5)));

try
{
  // keep nesting to a minimum
  if (!$name)
  {
    throw new Exception("Name not given.");
  }
  if (!$option)
  {
    throw new Exception("Invalid option given.");
  }

  // remainder of the code

}
catch (Exception $e)
{
  // do something in case the input is invalid, e.g.
  printf('<p class="error">%s</p>', $e->getMessage());
}

Was This Post Helpful? 1
  • +
  • -

#3 prefix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-April 12

Re: Posting a topic on a website?

Posted 13 April 2012 - 07:38 AM

Hey, and thanks for your reply.

What I am currently trying to do is basically I have a file, e.g an application where you fill out forms. The value inside those textboxes are supposed to be added to the topic then click the "Add topic" button.
The script will be hosted on the same website the topic will be posted on if that makes the task easier.

Thanks.

This post has been edited by Dormilich: 13 April 2012 - 07:39 AM
Reason for edit:: removed quote

Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,238
  • Joined: 08-June 10

Re: Posting a topic on a website?

Posted 13 April 2012 - 08:18 AM

View Postprefix, on 13 April 2012 - 04:38 PM, said:

The script will be hosted on the same website the topic will be posted on if that makes the task easier.

not really …

anyways, how do you save the topics?
Was This Post Helpful? 0
  • +
  • -

#5 prefix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-April 12

Re: Posting a topic on a website?

Posted 13 April 2012 - 08:37 AM

View PostDormilich, on 13 April 2012 - 08:18 AM, said:

View Postprefix, on 13 April 2012 - 04:38 PM, said:

The script will be hosted on the same website the topic will be posted on if that makes the task easier.

not really …

anyways, how do you save the topics?


The board is powered by IPB, so I guess the topics are "saved" in a MySQL DB if that's the answer you are looking for.
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,238
  • Joined: 08-June 10

Re: Posting a topic on a website?

Posted 13 April 2012 - 08:48 AM

there should be a way to "post a topic" by the IPB software itself.
Was This Post Helpful? 0
  • +
  • -

#7 prefix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-April 12

Re: Posting a topic on a website?

Posted 13 April 2012 - 08:54 AM

View PostDormilich, on 13 April 2012 - 08:48 AM, said:

there should be a way to "post a topic" by the IPB software itself.


So you mean posting the topic?

As in this:

<input type="submit" name="dosubmit" value="Post New Topic" tabindex="0" class="input_submit" accesskey="s">



I don't know if you can post a topic via the URL.
Sorry if I don't get what you mean exactly.
Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,520
  • Joined: 23-August 08

Re: Posting a topic on a website?

Posted 13 April 2012 - 09:04 AM

Why does it sound like you're trying to spam a forum?
Was This Post Helpful? 1
  • +
  • -

#9 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,205
  • Joined: 19-January 10

Re: Posting a topic on a website?

Posted 13 April 2012 - 09:10 AM

He said it's hosted on the same server, so lets give him a correct answer for his situation.

You shouldn't be trying to post your data to anywhere. You should study the documentation (if there is any) and figure out how exactly the topics are stored. From there, you can store your new topics into the database and the forum software should see it as it's own (and display it and everything). If there's no documentation, just use the forum software to post a topic and look inside each of your tables and try to figure out what's related. Better yet, find the scripts that handle forum posting, and take a look at the queries and just copy them.
Was This Post Helpful? 1
  • +
  • -

#10 prefix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-April 12

Re: Posting a topic on a website?

Posted 13 April 2012 - 09:11 AM

View PostJackOfAllTrades, on 13 April 2012 - 09:04 AM, said:

Why does it sound like you're trying to spam a forum?


I am not. I am creating an application form and it will create a new thread on the forum with the values inside the textboxes.

http://gyazo.com/b3c....png?1334332693

Posted Image
Was This Post Helpful? 0
  • +
  • -

#11 prefix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-April 12

Re: Posting a topic on a website?

Posted 13 April 2012 - 09:16 AM

View Postcreativecoding, on 13 April 2012 - 09:10 AM, said:

He said it's hosted on the same server, so lets give him a correct answer for his situation.

You shouldn't be trying to post your data to anywhere. You should study the documentation (if there is any) and figure out how exactly the topics are stored. From there, you can store your new topics into the database and the forum software should see it as it's own (and display it and everything). If there's no documentation, just use the forum software to post a topic and look inside each of your tables and try to figure out what's related. Better yet, find the scripts that handle forum posting, and take a look at the queries and just copy them.


I should have thought of that. I feel pretty dumb right now... Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1