php에서 넘겨받은 변수 값을 다시 다른 파일에 넘기는 방법좀 알려주세요

shoutskw의 이미지

우선 자유게시판을 만들고 있는 상황임을 알려드립니다. 변수 num은 개시 글의 번호 입니다.

view.php 문서에서 num변수를 아래와 같은 명령으로 passwd_modify.php에 전달했습니다.

echo ("
          <a href='passwd_modify.php?num=$num&page=$page'>
<img src='img/i_edit.gif' border=0>&nbsp</a>
 
)" ;

num전달받은 passwd_modify.php에서는 아래와 같은 명령으로 전달받은 값을 확인할 수 있었습니다.

<?php
$num = $_GET[num];
echo $num;

?>

그런데 passwd_modify.php는 패스워드를 입력받는 텍스트상자만이 존재하는 페이지입니다. "확인"버튼을 누르면 modify_form.php로 연결되어야 해서 아래와 같이 소스를 만들었습니다.


<form name=password method=get action="modify_form.php">
            <font size="-1" face="돋움"> 비밀번호 </font>
            <input class=c1 type="password" name="passwd" size="15"  maxlength="10"></input>
            <input type='image' src='img/button_ok.gif' border=0>
 
</form>

passwd_modify.php파일에서 modify_form.php파일을 열 때 num(개시글의 번호)의 값도 넘겨야하고 패스워드도 넘겨야하는데 제가 아는 시기으로는 한가지밖에 못 넘겨서요;; 고수님들의 조언부탁 드립니다^^

김정균의 이미지

일단 HTML에서 method="value" 와 같이 value가 숫자가 아닐 경우에는 quote를 해 주는 것이 좋습니다.
그리고 quote시에는 single quote보다 double qoute가 렌더링 시에 더 빠릅니다.
그리고 font tag보다는 span tag에 style sheet를 이용하시는 것이 좋습니다.

원하시는 바는 input의 hidden type을 이용하여 넘길 수 있으며, password와 같은 정보는 get 보다는
post로 넘기시는 것이 좋습니다.

<form name="password" method="post" action="modify_form.php">
            <span style="size: 1em; font-family="돋움,sans-serif"> 비밀번호 </span>
            <input class="c1" type="password" name="passwd" size="15" maxlength="10">
            <input type="image" src="img/button_ok.gif" border=0>
            <input type="hidden" name="num" value="<?php echo $_GET['num']; ?>">
</form>

tael의 이미지

설명 잘 해주셔서 추가적인 설명은 필요없을 것 같네요.
input type을 hidden으로 해주시면 많은 변수도 넘겨줄수있습니다:D

그리고 quote시에는 single quote보다 double qoute가 렌더링 시에 더 빠릅니다.

근데 single 보다 double qoute가 렌더링시 빠르다는 부분은 생각해 본적이 없는데,
어떤 근거로 더 빠른 건가요?
오히려 일반적인 상황에서 둘중에 뭐가 더 빠를까? 라고 생각한다면 저는 싱글쿼트가 빠를 것 같거든요.
정규식이라던가를 생각해보면(여기선 상관없겠지만 일반적으로) 분석연산이 빠져서 약간 더 빠를 수도 있겠다는 생각이 드네요.
혹시 php 내부 로직을 확인해 보신건지요?
- TaeL

- TaeL

keke111의 이미지

php에서가 아니라 html에서 인것 같은데요?

브라우저가 html파싱시 double qoute를 우선하기 때문인것 같습니다.

aero의 이미지

일반적인 생각으로는 double quote(" ")는 변수가 들어있을경우 값을 보간(interpolation)하기 때문에 보간할 변수가 있는지 확인하고 있으면 보간하는 시간이 더 걸릴 것이라고 생각 되는데요.

그래서 PHP나 Perl이나 sinlge/double quote의 동작 방식이 비슷하니 Perl의 경우를 비교해봤습니다.

#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark;
 
timethese( 1000000, {
    single_quote => sub { my $str = 'abcdefg1234567'; },
    double_quote => sub { my $str = "abcdefg1234567"; },
});

결과

Benchmark: timing 1000000 iterations of double_quote, single_quote...
double_quote:  1 wallclock secs ( 0.29 usr +  0.00 sys =  0.29 CPU) @ 3448275.86/s (n=1000000)
            (warning: too few iterations for a reliable count)
single_quote:  0 wallclock secs ( 0.20 usr +  0.00 sys =  0.20 CPU) @ 5000000.00/s (n=1000000)
            (warning: too few iterations for a reliable count)

Perl은 single quote가 1.45 배정도 빠르군요.

aero의 이미지

아 html 얘기였군요~ :)

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.