Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8846407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:58:35+00:00 2026-06-14T11:58:35+00:00

I am a absolute beginner in PHP and I need some help with my

  • 0

I am a absolute beginner in PHP and I need some help with my first scipt.

I have an array like this:

$ids = array("test1", "testa", "test2", "testv");

This is my full code:

<?php
$ids = array("test1", "testa", "test2", "testv");
$id = $_GET['id'];
if($id  == null){$done .= "Wrong ID";}
else if ($id  == $ids[0])
{
$laenge = 8;
for($i=0;$i<$laenge;$i++){$rnd = rand(1,62);
if ($rnd <= 10){$rnd += 47;}else if($rnd <= 36){$rnd += 54;}
else{$rnd += 60; }
$done .= chr($rnd);
}
}?>

now I will check the input with an GET variable of the array ( script.php?id= ).

at example script.php?id=test1 <<< Works great because of ($id == $ids[0]) but how can I get it to work that only (all) the variables from my array ($ids) are accepted

at example:

script.php?id=test1 = ok
script.php?id=testa = ok
script.php?id=test2 = ok
script.php?id=testv = ok
script.php?id=bla   = Not ok

I hope your understand my problem and can help me.
Thank you in advance 🙂

EDIT:
Thanks for your help but when i use this so

<?php
$ids = array("test1", "testa", "test2", "testv");
if(in_array($_GET['id'], $ids) 
{

$laenge = 8;
for($i=0;$i<$laenge;$i++){$rnd = rand(1,62);
if ($rnd <= 10){$rnd += 47;}else if($rnd <= 36){$rnd += 54;}
else{$rnd += 60; }
$gutschein .= chr($rnd);

} else {
echo 'Wrong ID';
}

}?>

i become an whitepage, sorry im totay new in php

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:58:36+00:00Added an answer on June 14, 2026 at 11:58 am

    You can use in_array to see if a value is in a given array.

    if(in_array($_GET['id'], $ids)) {
      // do stuff
    } else {
       echo 'Wrong ID';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Absolute beginner question: I have a template file index.html that looks like this: ...
I am an absolute beginner to WPF applications and need some help. All I’m
I am absolute beginner in Flash, and AS3. I need to make dynamically some
I have a form field in Drupal which I need some help with. The
I am an absolute beginner in this field. I have written the following code
Absolute beginner question here. I have two lists in mathematica. The first one was
I'm an absolute beginner, and I need to have a button to invert two
I'm almost an absolute beginner in Python, but I am asked to manage some
[First, I'm an absolute beginner. I tried to express myself as good as I
I have an absolute beginner question here. I'm having trouble getting multiple checkbox entries

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.