Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Posting to a URL

    I have an application that posts to a URL whenevery X Y or Z happens. This URL is very crude.

    accountname=testaccount&action=Add&actionDate=2005-04-30T01:02:49.760Z&IDs=1234567&itemType=Media&titles =testfile&userEmail=test@test.com&userID=9998767

    So basicly what this says is that user test added a file to testaccount and the date that this took place as well as the title of that file. This URL is not very pretty to look at, whats my best way to clean this up so that it is more pleasing to the eye? is that possible with PHP?

    I also have the ability to use an JSP page, a PHP page, a CGI script, a .NET application, or any other web application that can be invoked from a URL.

    My second issue is that I have multiple "accounts" that either need to post to a seperate page OR to the same page but again this would have to be much easier to read than the current URL that I get back.



    So instead of getting back: accountname=testaccount&action=Add&actionDate=2005-04-30T01:02:49.760Z&IDs=1234567&itemType=Media&titles =testfile&userEmail=test@test.com&userID=9998767

    I would rather see:

    Account Name: Testaccount
    Action: Add
    Action Date:
    ID's:
    ItemType: Media
    Title: Testfile
    UserEmail: test@test.com
    UserID: 9998767

    Ideally I'm imagining output like the one above that does two things one that gets emailed to those that I specify and two is that its also displayed on the .php page.

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    I'm confused about your problem. It looks like all you have is a simple GET query string. PHP can handle that easily just by using $_GET - standard form handling. If you don't want it in the URL, use POST instead, and then use the PHP $_POST variable. Then manipulate your data however you want.
    Are you a Help Vampire?

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry I'm not really a programmer - was looking more for "use this code" - I had asked over at the ASP message boards http://www.aspmessageboard.com/showthread.php?t=232309 - but in the end figured out that the web server I'm using doesn't support asp...

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Where would you rather see that output?

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    New Coder
    Join Date
    Aug 2006
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would like the output in two places, one is on a webpage and two is for it to get emailed. Both should be in the following format:

    Account Name: Testaccount
    Action: Add
    Action Date:
    ID's:
    ItemType: Media
    Title: Testfile
    UserEmail: test@test.com
    UserID: 9998767
    Last edited by tb582; 08-27-2009 at 11:30 PM.

  • #6
    New Coder
    Join Date
    Aug 2006
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tb582 View Post
    I would like the output in two places, one is on a webpage and two is for it to get emailed. Both should be in the following format:

    Account Name: Testaccount
    Action: Add
    Action Date:
    ID's:
    ItemType: Media
    Title: Testfile
    UserEmail: test@test.com
    UserID: 9998767
    Can anyone provide me with the code?

  • #7
    Regular Coder
    Join Date
    Apr 2008
    Posts
    685
    Thanks
    15
    Thanked 105 Times in 104 Posts
    How are you submitting the data to the PHP page in the first place, via a form of some sort?
    As explained earlier it would seem like it's being sent via the get method, when post is really what you are looking for.

    So
    1. How are you submitting the data
    2. If you can post up the .php file that recieves the data

    then i or someone can post up a solution!

  • #8
    New Coder
    Join Date
    Aug 2006
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Scriptet View Post
    How are you submitting the data to the PHP page in the first place, via a form of some sort?
    As explained earlier it would seem like it's being sent via the get method, when post is really what you are looking for.

    So
    1. How are you submitting the data
    2. If you can post up the .php file that recieves the data

    then i or someone can post up a solution!
    The data is coming from a program that I give it a URL to "post" to. So whenevery X Y or Z happens. It will post the follwing to the URL given:

    accountname=testaccount&action=Add&actionDate=2005-04-30T01:02:49.760Z&IDs=1234567&itemType=Media&titles =testfile&userEmail=test@test.com&userID=9998767

    I just want two thing, one to make the above presentable and two is to have the same presentable version emailed.

  • #9
    Regular Coder
    Join Date
    Apr 2008
    Posts
    685
    Thanks
    15
    Thanked 105 Times in 104 Posts
    OK Well you didn't really answer either of my questions...but anyway

    Here is how to obtain data from a URL in PHP:
    A page with the following URL:
    mysite.com/mypage.php?accountname=testaccount&action=Add&actionDate=2005-04-30T01:02:49.760Z&IDs=1234567&itemType=Media&titles =testfile&userEmail=test@test.com&userID=9998767

    Then mypage.php would be:
    PHP Code:
    <html>
    <head>
    </head>
    <body>
    <?php
    $accountname 
    $_GET['accountname'];
    $action $_GET['action'];
    $actionDate $_GET['actionDate'];
    $IDs $_GET['IDs'];
    $itemType $_GET['itemType'];
    $titles $_GET['titles'];
    $userEmail $_GET['userEmail'];
    $userID $_GET['userID'];

    echo 
    "Account Name: ".$accountname."<br />";
    echo 
    "Action: ".$action."<br />";
    echo 
    "Action Date: ".$actiondate."<br />";
    echo 
    "IDs: ".$IDs."<br />";
    echo 
    "Item Type: ".$itemtype."<br />";
    echo 
    "Title: ".$titles."<br />";
    echo 
    "User Email: ".$userEmail."<br />";
    echo 
    "User ID: ".$userID."<br />";
    ?>
    </body>
    </html>
    This would output the information on the screen. You can then proceed to email this information, just check that this works first.

    If you were on about making the URL pretty then you'd have to submit the data via a form rather than using the URL.
    Last edited by Scriptet; 08-31-2009 at 02:17 AM. Reason: code typos

  • #10
    New Coder
    Join Date
    Aug 2006
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks,

    So with that code, formatting is correct but I do not see any output. Is there any debugging that can be added to see what if any values are trying to be posted?

  • #11
    Regular Coder
    Join Date
    Apr 2008
    Posts
    685
    Thanks
    15
    Thanked 105 Times in 104 Posts
    Try this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <?php
    if($_GET){
    	echo "The Contents of the $_GET array are shown below:";
    	//Loop through get array
    	foreach($_GET as $key => $value){
    		$num++;
    		echo $num." Key: ".$key." Value: ".$value."<br />";
    	}
    	
    	$accountname = $_GET['accountname'];
    	$action = $_GET['action'];
    	$actionDate = $_GET['actionDate'];
    	$IDs = $_GET['IDs'];
    	$itemType = $_GET['itemType'];
    	$titles = $_GET['titles'];
    	$userEmail = $_GET['userEmail'];
    	$userID = $_GET['userID'];
    
    	echo "Account Name: ".$accountname."<br />";
    	echo "Action: ".$action."<br />";
    	echo "Action Date: ".$actiondate."<br />";
    	echo "IDs: ".$IDs."<br />";
    	echo "Item Type: ".$itemtype."<br />";
    	echo "Title: ".$titles."<br />";
    	echo "User Email: ".$userEmail."<br />";
    	echo "User ID: ".$userID."<br />";
    }
    else{
    	echo "<h1>No Values were found in the $_GET Array!</h1>";
    }
    ?>
    
    </body>
    </html>

  • #12
    New Coder
    Join Date
    Aug 2006
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No Values were found in the Array Array! hmmm

  • #13
    Regular Coder
    Join Date
    Apr 2008
    Posts
    685
    Thanks
    15
    Thanked 105 Times in 104 Posts
    I just tested it myself and it works, copy and paste the URL of the page you are getting this message.

    It should be like this:

    mysite.com/mypage.php?accountname=testaccount&action=Add&actionDate=2005-04-30T01:02:49.760Z&IDs=1234567&itemType=Media&titles =testfile&userEmail=test@test.com&userID=9998767

  • #14
    New Coder
    Join Date
    Aug 2006
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    2009-08-31 06:13:15,173 [SendNotification30815[130983018]] Posting to http://mysite.com/testing.php with data account=testaccount&action=Modify&actionDate=2009-08-31T13%3a13%3a15.543Z&IDs=562158454&titles=this is a test&server=http://testserver.com&statusValues=OK&previousStatusValues=Error&itemType=Media&userEmail=test_test%40mysit e.com&userID=5621548645

  • #15
    Regular Coder
    Join Date
    Apr 2008
    Posts
    685
    Thanks
    15
    Thanked 105 Times in 104 Posts
    What is that, i'm assuming instead of mysite.com you have your URL there in reality.

    When it says with data etc.. how exactly is it sending this data?

    For what I have done to work it would need to post it like this:

    Code:
    http://mysite.com/testing.php?account=testaccount&action=Modify&actionDate=2009-08-31T13%3a13%3a15.543Z&IDs=562158454&titles=this is a test&server=http://testserver.com&statusValues=OK&previousStatusValues=Error&itemType=Media&userEmail=test_test%40mysit e.com&userID=5621548645
    Note all the data comes after a question mark in the URL


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •