Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Przekazywanie pewnej wartości z urla to formularza
Forum PHP.pl > Forum > Po stronie przeglądarki > JavaScript
Azz
Witam

Jako że kompletnie nie znam sie na js ale potrzebuje cos zrobic z moim fantem

Mianowicie dajmy na to w przegladarce czy to IE czy FF
wyswietli mi sie link
np.
http://domena.com/index.php?&act=shop&func...oney&user=Admin
lub
http://domena.com/index.php?&act=shop&func...money&user=Demo

i aby skrypt pobierał końcówke URLA to jest Admin lub Demo

i wlepiał ją do pola w formularzu

Czy takie coś jest możliwe ?
revyag
Żeby w przeglądarce pojawił się taki link to wcześniej trzeba coś kliknąć, więc to o co pytasz można banalnie zrobić w php. Jaki jest powód tego że chcesz to zrobić korzystająć z js ?
Azz
tak klikne link zostane przekierwoany na inna pod strone i koncówka tego linku (nazwa usera) powinna zostać wpisana w jedno poloe formularzu
revyag
No to ja pytam, dlaczego chcesz to robić przy użyciu js ?
Azz
myslalem ze mozna zrobic to tylko przy JS nie wiedzialem ze za pomoca php tez mozna smile.gif jesli tak to jeszcze lepiej

Edit: Ktos pomoże smile.gif?
cadavre
  1. <?php
  2. $user = $_GET['user'];
  3. echo "<input type='text' value='$user' />";
  4. ?>
Azz
tutaj mam kawałek kodu:

Kod
if ($func=="transfer_money")
{
    if ($code=="")
    {
     $templateform = loadtemplate("shop_transfer_money_1");
     eval(template);
     $output = $templateform;
     print_and_exit();
    } elseif ($code=="send")
    {
     global $HTTP_POST_VARS,$ibforums;
     if (!isset($HTTP_POST_VARS["money"]) OR !is_numeric($HTTP_POST_VARS["money"]) OR $HTTP_POST_VARS["money"]<=0)
     {
         shoperror("Sorry, you can't send 0 {$ibforums->vars["shop_currencyname"]}, or a negative amount, nice try though!");
     }
     if ($HTTP_POST_VARS["money"] > $ibforums->member["points"])
     {
         shoperror("You do not have enough {$ibforums->vars["shop_currencyname"]} to send " . currencyformat($HTTP_POST_VARS["money"]));
     }
    
     $money = $HTTP_POST_VARS["money"];

     if (!isset($HTTP_POST_VARS["username"]))
     {
         shoperror("You must enter a member to send {$ibforums->vars["shop_currencyname"]} to!");
     }
     $username = addslashes($HTTP_POST_VARS["username"]);
     $DB->query("SELECT id FROM _ipb_members WHERE name='{$username}' LIMIT 1");
     if ($DB->get_num_rows()==0)
     {
         shoperror("Recipient does not exist, correct spelling?");
     }
     $id = $DB->fetch_row();
     $id = $id["id"];
    
     $DB->query("UPDATE _ipb_members SET points = points + {$money} WHERE id={$id} LIMIT 1");
     $DB->query("UPDATE _ipb_members SET points = points - {$money} WHERE id={$ibforums->member["id"]} LIMIT 1");
        
        shop_addlog(array("type" => "M", "targetmemberid" => $id, "actiontext" => "Transfered {$money} {$ibforums->vars["shop_currencyname"]}" ));
        
        $post = "";
        if (isset($HTTP_POST_VARS["post"]))
        {
            $message = htmlspecialchars($HTTP_POST_VARS["post"]);
        }
        
        $recipient = $username;
        $sender = $ibforums->member["name"];
        global $std;
        $timestamp = $std->get_date(time(), "LONG");
        $servicebotname = $ibforums->vars["shop_botname"];
        $currencyname = $ibforums->vars["shop_currencyname"];
        $currency = currencyformat($money);
        
        $templateform = loadtemplate("transfer_money_pm");
        eval(template);
        $pm = $templateform;
        unset($templateform);
        global $std; $pm = $std->clean_value($pm);

        send_pm(array("recipientid" => $id, "title" => "{$ibforums->member["name"]} has sent you some {$ibforums->vars["shop_currencyname"]}", "message" => $pm, "senderid" => $ibforums->member["id"]));
        redirect("{$currency} sent to {$recipient}", "act=shop");
        exit;
    }
    else    
    {
     shoperror("Contact your board administrator and ask to be banned... no messing with board input :P");
    }
    
}


A tu kawałek skina do tego
Kod
<form name="transfer" method="post" action="<!!URL>&func=transfer_money&code=send">

<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr>
<td class='titlemedium' colspan="2">Send <@ibforums->vars["shop_currencyname"]@></td>
</tr>
<tr>
<td class="postfoot" colspan="2">Recipient</td>
</tr>
<tr>
<td class="row1" align="right">Send <@ibforums->vars["shop_currencyname"]@> to:</td>
<td class="row2">

//Tutaj powinien sie wpisywac user
<input type="textbox" class='forminput' name="username" value=''>
///Tutaj

</td>
</tr>

<tr>
<td class="postfoot" colspan="2">Amount of <@ibforums->vars["shop_currencyname"]@></td>
</tr>

<tr>
<td class="row1" align="right"><@ibforums->vars["shop_currencyname"]@>:</td>
<td class="row2"><input type="textbox" class='forminput' name="money" value=""></td>
</tr>

<tr>
<td class="postfoot" colspan="2">Attached Message - included in recipient's PM reciept</td>
</tr>


<tr>
<td class="row1" colspan="2"><textarea name="post" cols="50" rows="6"> </text-area>
</td></tr>

<tr>
<td class='mainfoot' align="center" colspan="2"><input type="submit" name="submit" value="Send Money" tabindex='4' class='forminput' accesskey='s'>
</td></tr>
</table>


Gdy np. mam link taki jak podałem wcześniej w pole "username" powinno wpisać się user z linku
cadavre
  1. //Tutaj powinien sie wpisywac user
  2. <input type="textbox" class='forminput' name="username" value="<?php echo $_GET['user']; ?>">
  3. ///Tutaj
Azz
w formie wyswietla sie:

Kod
<?php echo $_GET['user']; ?>


Edit: Skin przechowywany jest w bazie, na innym forum widziałem takie coś
zrobione pisałem do admina jednak nie chciał pomóc
cadavre
To może całość jest wsadzona pod php. Pokaż całą stronę ze skinem.
Azz
Pomyslalem i rozwiazalem problem inaczej smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.