1

I want to flood some random data in a PHP form. Can I do it?

I want to actually test my website and database ofcourse. All I want to know that is it capable of handling if multiple registration is done at same time.

Himanshu Shankar
  • 96
  • 1
  • 2
  • 8

2 Answers2

2

cURL is a very good tool to fill up a (POST) form a submit it. You may find a cURL library implementation in PHP, so you can use a "familiar" language to get random data, but you can also use the command line version.

m c
  • 1,104
  • 1
  • 12
  • 21
1

First, create pages that echo data from source.

data1.php
data2.php
data3.php
data4.php

Second create a php page that will do the following:

  1. Create variables from data sources.
  2. Pass variables into array.
  3. Randomly select a specific variable.
  4. Echo results into page.

    // variables from data
    $var1 = file_get_contents('data1.php');
    $var2 = file_get_contents('data2.php');
    $var3 = file_get_contents('data3.php');
    $var4 = file_get_contents('data4.php');

    // pass variables into array
    $data = array($var1, $var2, $var3, $var4,);

    $dkey = array_rand($data); // random selection
    echo 'Data: '.$data[$dkey]; // echo selection

Your finished code will look like this:

<?php
$var1 = file_get_contents('data1.php');  
$var2 = file_get_contents('data2.php');   
$var3 = file_get_contents('data3.php');   
$var4 = file_get_contents('data4.php');   

$arr = array($var1, $var2, $var3, $var4,);  

$key = array_rand($arr);    
echo 'Data: '.$arr[$key];   
?>
Mike Stratton
  • 463
  • 1
  • 7
  • 20
  • So I put some usernames in data1.php and password in data2.php and emailids in data3.php! The finished code will take random values from data1, data2 and data3 and assign it to var1 var2 and var3 respectively What I don't get is how it's going to post it on the registration page? Sorry I am not so much of a professional! – Himanshu Shankar Jun 09 '15 at 08:28
  • Why would you want to display user names and passwords on your registration form? – Mike Stratton Jun 09 '15 at 08:35
  • You can flood a form with random data. Passing user logon credentials as the source of data is a very, very bad idea. – Mike Stratton Jun 09 '15 at 08:37
  • I just want to test my project if it can handle mass registration. So ofcourse I will put some random data. I was saying that in data1.php lets say I put some random data that will go against username in the form and so on.. What's the next step? How do I flood these data? – Himanshu Shankar Jun 09 '15 at 08:42
  • Ok, I understand now. You would like to test your site for it's ability to handle traffic. To many variables for this question to be answered with the information you have given. Shared hosting, VPS, dedicated server, and Cloud will effect speed. The efficiency of your code will also effect the speed. The weight of your html will also effect this. I suggest going to your local library and getting a book or two out on web development. – Mike Stratton Jun 09 '15 at 08:51
  • I just want to test it on my local server plz. So I want to flood data in the forms! – Himanshu Shankar Jun 09 '15 at 09:22