0

please need help html form auto ip fill

<form action='konkursas.php' method='post'>
    <p>El. pašto adresas</p><input type='email'  title="Čia turėtų būti jūsų email." name ='nail' size= '30'/>
    <input type='ip'  title="jusu ip." name ='autofillip' size= '30'/>
    <br />
    <br />        
    <input type='submit' name='submit' value='OK'/>
    <br />
</form>

php file

<?php
if (isset($_POST['submit'])) {
    $file = fopen('konkursas.txt','a+');
    $email = $_POST['nail'];
    $fmail = $email.PHP_EOL;
    fwrite($file,$fmail);
    fclose($file); 
    print_r(error_get_last());

    header("Location: http://www.mypage.com") ;
}

?>

Please help :)

4
Contributors
23
Replies
103
Views
4 Years
Discussion Span
Last Post by AndrisP
Featured Replies
  • 1

    > how to create.ip ban script and banned ip redirect to ban.html ? Search the current IP in your file. If found, redirect to your ban page. Read More

  • 1

    Do you mean automatically fill in the IP of the client submitting the form? If the form is on a PHP page, use `$_SERVER['REMOTE_ADDR']` to get the IP. Read More

  • 1

    > but. i dont know how do this. Have a look at [file](http://php.net/manual/en/function.file.php) to read your file. Then you can use a loop to check each line against your IP. Read More

1

Not need input field "ip" in form - user can change it.

    <?php
    if (isset($_POST['submit'])) {
    $file = fopen('konkursas.txt','a+');
    $email = $_POST['nail'];
    fwrite($file,$email." [".$_SERVER['REMOTE_ADDR']."]".PHP_EOL);
    fclose($file);
    print_r(error_get_last());
    header("Location: http://www.mypage.com") ;
    }
    ?>

Edited by AndrisP

Votes + Comments
Thanks :)
1

how to create.ip ban script and banned ip redirect to ban.html ?

Search the current IP in your file. If found, redirect to your ban page.

Votes + Comments
but. i dont know how do this.
1

Do you mean automatically fill in the IP of the client submitting the form?

If the form is on a PHP page, use $_SERVER['REMOTE_ADDR'] to get the IP.

Votes + Comments
i know but thanks.
1

for example:

RewriteEngine on

RewriteCond %{REMOTE_ADDR} ^127.0.0.1$
RewriteRule !(^ban_page.html) /ban_page.html [R]

Edited by AndrisP

0
    <form action='konkursas.php' method='post'>
    <p>El. pašto adresas</p><input type='email' title="Čia turėtų būti jūsų email." name ='nail' size= '30'/>
    <br />
    <br />
    <input type='submit' name='submit' value='OK'/>
    <br />
    </form>

I need users can fill one time per ip. then form changes to image. ?

Edited by sigitas.darguzas: error

1

if you save in file as

<?php

fwrite($file,$email.";".$_SERVER['REMOTE_ADDR'].";".PHP_EOL);

?>

you can use this function

<?php

function parsefile($filename){
    $file = @file($filename);
    while(list($key,$val)=each($file)){
        $line = explode(";",$val);
        if($line[1]==$_SERVER['REMOTE_ADDR']) return true;
        }
    return false;
    }

?>
0

check IP address

if (parsefile("konkursas.txt")){ echo "Error message"; }
else { echo "<form> ..... </form>"; }
0
<!DOCTYPE html>
<title>title</title>
<link rel="shortcut icon" href="images/skerdykla.ico" type="image/icon">
<meta charset="utf-8" />
<link rel="stylesheet" href="styles/elegant-press.css" type="text/css" />
<script src="scripts/elegant-press.js" type="text/javascript"></script>
</head>
<body>
<div id="fb-root"></div>

<SCRIPT TYPE="text/javascript">
var message="Sorry, right-click has been disabled";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
</SCRIPT> 


<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/lt_LT/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="main-container">
  <header>
    <h1><a href="index.html">name</a></h1>
    <link rel="icon" href="/images/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<embed src=muzika/evizija.mp3 autostart=true hidden=true>
</embed> 
  </header>
</div>
<div class="main-container">
  <div id="nav-container">
   <nav> 
    <ul class="nav">
      <li class="active"><a href="index.html" name="Pagrindinis puslapis">Pagrindinis</a></li>
          <li><a href="index.html" name="forumas" >Forumas</a></li>
          <li><a href="index.html" name="AMXBAN'ai" >AMXBAN</a></li>
      <li><a href="index.html" name="Kontaktai">Kontaktai</a></li>
      </ul>
   </nav> 
    <div class="clear"></div>
  </div>
</div>
<div class="main-container">
  <div class="container1">
  <div id="mySlides">
    <div id="slide1">    
        <img src="images/slider1.jpg" alt="Slide 1 jFlow Plus" />
        <span><b class="slideheading">Nauja pradžia .</b><br />cs-skerdykla.tk projektas Grįžo!<a href="#" title="Coolness" class="readmore">Skaityti daugiau!</a></span>
    </div>       
    <div id="slide2">
        <img src="images/slider2.jpg" alt="Slide 2 jFlow Plus" />
        <span><b class="slideheading">Pagalba.</b><br />Susisiekite skype:era1321<a href="#" title="Coolness" class="readmore">Skaityti daugiau!</a></span>
    </div>   
    <div id="slide3">
        <img src="images/slider3.jpg" alt="Slide 3 jFlow Plus" />
        <span><b class="slideheading">Kolektyvas</b><br />Puslapis po truputėlį didiną savo gretas!<a href="#" title="Coolness" class="readmore">Skaityti daugiau!</a></span>
    </div>
</div>

<div id="myController">
   <span class="jFlowControl"></span>
   <span class="jFlowControl"></span>
   <span class="jFlowControl"></span>
</div>

<section class="jFlowPrev"><div></div></section>
<section class="jFlowNext"><div></div></section>
<br />
<br />

    <article class="box" id="home_featured21">
      <div class="block"><h2>Serveris</h2>
 <iframe src='http://monitors.cancel.lt/info3.php?ip=82.135.154.176&port=27016&g=cs' scrolling='no' frameborder='0' width='340' height='130'></iframe>

      </div>
      <div class="block"><h2></h2>
<br /><br />


      </div>
      <div class="block last"><h2>Konkursas<br> dėl Vip,Admin</h2>
      if (parsefile("konkursas.txt")){ echo "Error message"; }
else { echo "<form><form action='konkursas.php' method='post'>
    <p>El. pašto adresas</p><input type='email'  title="Čia turėtų būti jūsų email." name ='nail' size= '30'/>
    <br />
    <br />
    <input type='submit' name='submit' value='OK'/>
    <br />
</form></form>"; }
      </div>
      <div class="clear"></div>
    </article>

 </div>


<br /><br />

     <div class="container2">
     <article id="home_featured2">
      <ul>
        <li>
          <div class="imgholder"><a href="images/slide1.jpg" data-gal="prettyPhoto[featured]" title="First Featured Title"><img src="images/featured1.jpg" width="275" height="145" alt="" /></a></div>
          <h4>Startas.</h4>
          <p>Pirmos akimirkos startavus serverį</p>
        </li>
        <li>
          <div class="imgholder"><a href="images/slide2.jpg" data-gal="prettyPhoto[featured]" title="Second Featured Title"><img src="images/featured2.jpg" width="275" height="145" alt="" /></a></div>
          <h4>Startas.</h4>
          <p>Pirmos akimirkos startavus serverį</p>
        </li>
        <li class="last">
          <div class="imgholder"><a href="images/slide3.jpg" data-gal="prettyPhoto[featured]" title="Third Featured Title"><img src="images/featured3.jpg" width="275" height="145" alt="" /></a></div>
          <h4>Startas.</h4>
          <p>Pirmos akimirkos startavus serverį</p>
        </li>
      </ul>
      <br class="clear" />
    </article>
  </div>
</div>

<div class="callout"> 
    <div class="calloutcontainer"> 
        <div class="container_12"> 
            <div class="grid"> 

    <article class="footbox last">
      <h2>Rask mus Facebook'e</h2>
      <div class="fb-like"
      data-href="https://www.facebook.com/pages/Cs-SkerdyklaTk/1420868914818550" data-colorscheme="light" data-layout="standard" data-action="like" data-show-faces="true" data-send="true">
      </div>
       </article>
            <div class="clear"></div> 
        </div> 
        <div class="calloutoverlay"></div> 
        <div class="calloutoverlaybottom"></div> 
    </div> 
</div> </div> 

<footer>
<div class="main-container">
    <p class="tagline_center"><p id="tagline2"> Email'as: <a href="mailto:sigitasdarguzas@gmail.com">sigitasdarguzas@gmail.com</a></p></p>
    <div id="fb-root"></div>
    </footer>
<br/>
 <footer>
<div class="main-container">
    <p class="tagline_left">Projektas susijunges su<a href="http://taboras.tk/" title="partneriai" target="_blank" >Taboras.Tk</a></p>
    <p class="tagline_right">Dizainas <a href="http://www.supergames.lt/user/31855-senas-vilkas/" title="skype:era1321" target="_blank" >Senas Vilkas!</a></p>
    <br class="clear" />
    <div id="fb-root"></div>

  </footer>

<br />
<br />
<script type="text/javascript" src="jQuery.tooltip.js"></script>
    </body>
</html>

error.

Edited by sigitas.darguzas: error

1

Put function to beginning of this file,

    <?php
    function parsefile($filename){
    $file = @file($filename);
    while(list($key,$val)=each($file)){
    $line = explode(";",$val);
    if($line[1]==$_SERVER['REMOTE_ADDR']) return true;
    }
    return false;
    }
    header("Content-type:text/html;charset=utf-8");
    ?>

edit lines 90-100

<div class="block last"><h2>Konkursas<br> dėl Vip,Admin</h2>
<?php if (parsefile("konkursas.txt")){ echo "Error message"; }
else { ?>
<form action='konkursas.php' method='post'>
<p>El. pašto adresas</p><input type='text' title="Čia turėtų būti jūsų email." name ='nail' size= '30'/>
<br />
<br />
<input type='submit' name='submit' value='OK'/>
<br />
</form>
<?php } ?>

and save this file as php

Edited by AndrisP

0

HTML - Hyper Text Markup Language, it is not script! Impossible to check text file without php.

1

e.g.

<?php 
// put php script - functions classes, methods etc

header("Content-type:text/html;charset=utf-8");
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>
"; ?>
<!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" xml:lang="en" lang="lt">

<head>
.....
</head>
<body>
<?php
// again php script in HTML body
?>
<p>print some HTML content</p>
<?php
// and again php script in HTML body
?>
</body>
</html>

Edited by AndrisP

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.