Buying small problem 3$ prize

Discussion in 'Programming' started by alincatalin, Mar 21, 2011.

  1. #1
    Hi guys i have a small problem hope someone can help me on this....

    I have this form
    Ex:

    <form action="newpage.php" method="get" >
    <input type="text" name="yourtext" value="yourtextetc" />
    <input type="text" name="urlname" value="inputurlname" />
    <input type="submit" value="create" />

    Then after user submits the form i get this in url ...
    http://mysite/newpage.php?yourtext=y...e=inputurlname

    Here is the problem:

    How can i convert
    http://mysite/newpage.php?yourtext=y...e=inputurlname

    In to

    http://mysite/inputurlname

    and in html i can see yourtextetc

    using php or javascript....

    First one to help with this problem will win 3$ paypal...
     
    alincatalin, Mar 21, 2011 IP
  2. militarysmurf

    militarysmurf Member

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    40
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    You'd have to use a .htaccess to do that. and your form would either need to use POST with a php header redirect or a javascript to accomplish your task
     
    militarysmurf, Mar 21, 2011 IP
  3. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    can you show me the code for this? example code?
     
    alincatalin, Mar 21, 2011 IP
  4. militarysmurf

    militarysmurf Member

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    40
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    militarysmurf, Mar 21, 2011 IP
  5. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    It will not work like that i tried something like that... because user adds those value and i don't think it is possible for user to edit htaccess values.....
    example
    <input type="text" name="yourtext" value="hi my name is Jimmy...user inputed this" />
    <input type="text" name="urlname" value="Jimmy" />

    So in browser Jimmy has to see this:
    In url address bar http://mysite/Jimmy

    and in html hi my name is Jimmy...user inputed this


    without using mysql ....




     
    alincatalin, Mar 21, 2011 IP
  6. Bogdanel

    Bogdanel Active Member

    Messages:
    77
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    65
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    Bogdanel, Mar 21, 2011 IP
  7. a3d

    a3d Well-Known Member

    Messages:
    409
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    
    RewriteCond %{REQUEST_URI} newpage.php$
    RewriteCond %{QUERY_STRING} ^urlname=([A-Za-z0-9\+]+)$
    RewriteRule ^(.*)$ /%1? [R=301,L]
    RewriteRule ^([^+]+)\+([^.]+)$ /$1-$2 [R=301,L]
    RewriteRule ^(.*)$ newpage.php?urlname=$1&a=1 [L]
    
    Code (markup):
    try this on htaccess .
    no php coding needed.
    if its not working,
    you need a little modification
     
    a3d, Mar 21, 2011 IP
  8. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    can you show me a example with the code i showed you ? if it works you will win.....
     
    alincatalin, Mar 21, 2011 IP
  9. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    ok one sec

     
    alincatalin, Mar 21, 2011 IP
  10. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #10
    same thing nothing happens in url....

    take a look

    http://1o.ro/test/

     
    alincatalin, Mar 21, 2011 IP
  11. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #11
    alincatalin, Mar 21, 2011 IP
  12. militarysmurf

    militarysmurf Member

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    40
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #12
    The rewrite cond works but it won't automatically generate the url, you'd not some basic javascript form processing for that. Bind the submit to a window.location command instead.
     
    militarysmurf, Mar 21, 2011 IP
  13. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #13
    Please send me a pm with your example so i can try it ....
     
    alincatalin, Mar 21, 2011 IP
  14. jubi

    jubi Peon

    Messages:
    182
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #14
    A bit ugly way, but might do:
    newpage.php:
    
    session_start();
    $_SESSION['yourtext']=$_GET['yourtext'];
    $_SESSION['inputurlname']=$_GET['inputurlname'];
    header("Location: http://mysite/$_SESSION['inputurlname']");
    
    Code (markup):
    .htaccess:
    
    I guess any from previous posts :)
    
    Code (markup):
    To get access to yourtext variable:
    
    echo $_SESSION['yourtext'];
    
    Code (markup):
     
    jubi, Mar 21, 2011 IP
  15. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #15
    nope nothing happens same thing using your code now....

    http://1o.ro

    Can you add a .htaccess also, to try your version of .htaccess....?



     
    Last edited: Mar 21, 2011
    alincatalin, Mar 21, 2011 IP
  16. jubi

    jubi Peon

    Messages:
    182
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #16
    check your inbox
     
    jubi, Mar 21, 2011 IP
  17. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #17
    i sent you a pm....
     
    alincatalin, Mar 21, 2011 IP
  18. alincatalin

    alincatalin Member

    Messages:
    392
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #18
    problem stil not solved:(
     
    alincatalin, Mar 21, 2011 IP
  19. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #19
    How about this for newpage.php
    
    <?php
    	$yourtext = $_GET["yourtext"];
    	$urlname = $_GET["urlname"];
    	mkdir($urlname);
    	$f = fopen($urlname."/index.html", "w");
    	fwrite($f,"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n");
    	fwrite($f,"<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n");
    	fwrite($f,"<head profile='http://gmpg.org/xfn/11'>\n");
    	fwrite($f,"<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n");
    	fwrite($f,"<title></title>\n");
    	fwrite($f,"</head>\n");
    	fwrite($f,"<body>\n");
    	fwrite($f,"<h1>".$yourtext."</h1>\n");
    	fwrite($f,"</body>\n");
    	fwrite($f,"</html>");
    	fclose($f);
    	header( "Location: ".$urlname) ;
    ?>
    
    Code (markup):
    I have no idea if that is safe or not, so caveat emptor mate! :p
     
    Last edited: Mar 21, 2011
    Cash Nebula, Mar 21, 2011 IP