• We just launched and are currently in beta. Join us as we build and grow the community.

How to Convert Text in CRC32 using PHP/MySQL

ClassiqMan

Mood Uplifter
C Rep
0
0
0
Rep
0
C Vouches
0
0
0
Vouches
0
Posts
161
Likes
91
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
In this article, we are going to learn how to Convert Text in CRC32 using PHP/MySQL. This simple program will demonstrate how to convert text in crc32. CRC32 creates 32-bit hash value.

Creating simple TextBox, buttons, and another TextBox for viewing the result of CRC32 to the form field as in the image below.
1_124.png

Here's the source code in the image above.
  1. <center

    >
  2. <div

    style

    =

    "border:2px solid blue; background:azure; width:500px; padding:20px;"

    >
  3. <form

    method

    =

    "post"

    >
  4. <h2

    style

    =

    "color:blue; font-family:cursive;"

    >

    Convert Text to Crc32</

    h2

    ><br

    >
  5. <input

    type

    =

    "text"

    name

    =

    "convert"

    style

    =

    "padding:5px; font-size:18px; width:245px; font-family:cursive;"

    placeholder=

    "Type Anything . . . . ."

    autofocus=

    "autofocus"

    >
  6. <input

    type

    =

    "submit"

    name

    =

    "crc32_convertion"

    value

    =

    "Convert"

    style

    =

    "padding:5px; font-family:cursive; font-size:18px; color:blue; background:azure; border:1px solid blue; border-radius:4px; cursor:pointer;"

    >
  7. </

    form

    >
  8. <br

    >
  9. <h2

    style

    =

    "color:blue; font-family:cursive;"

    >

    Crc32 Result</

    h2

    ><br

    >
  10. <input

    type

    =

    "text"

    value

    =

    ""

    style

    =

    "padding:5px; text-align:center; border:1px solid blue; color:white; font-size:18px; background:#1982d1; cursor:not-allowed; width:480px; "

    readonly><br

    ><br

    >
  11. </

    div

    >
  12. </

    center

    >

For the conversion of text to CRC32, we are going to put this PHP query to the TextBox to view the result.
This is the PHP query.
  1. <?php

  2. if

    (

    isset

    (

    $_POST

    [

    'crc32_convertion'

    ]

    )

    )

    {

    echo

    crc32

    (

    $_POST

    [

    'convert'

    ]

    )

    ;

    }

  3. ?>

Now, let's put to the TextBox.
  1. <h2

    style

    =

    "color:blue; font-family:cursive;"

    >

    Crc32 Result</

    h2

    ><br

    >
  2. <input

    type

    =

    "text"

    value

    =

    "<?php if(isset($_POST['crc32_convertion'])){ echo crc32($_POST['convert']); } ?>

    " style="padding:5px; text-align:center; border:1px solid blue; color:white; font-size:18px; background:#1982d1; cursor:not-allowed; width:480px; " readonly>

The complete source code.
  1. <!DOCTYPE html>
  2. <html

    >
  3. <head

    >
  4. <title

    >

    Convert Text to Crc32</

    title

    >
  5. </

    head

    >
  6. <body

    >

  7. <center

    >
  8. <div

    style

    =

    "border:2px solid blue; background:azure; width:500px; padding:20px;"

    >
  9. <form

    method

    =

    "post"

    >
  10. <h2

    style

    =

    "color:blue; font-family:cursive;"

    >

    Convert Text to Crc32</

    h2

    ><br

    >
  11. <input

    type

    =

    "text"

    name

    =

    "convert"

    style

    =

    "padding:5px; font-size:18px; width:245px; font-family:cursive;"

    placeholder=

    "Type Anything . . . . ."

    autofocus=

    "autofocus"

    >
  12. <input

    type

    =

    "submit"

    name

    =

    "crc32_convertion"

    value

    =

    "Convert"

    style

    =

    "padding:5px; font-family:cursive; font-size:18px; color:blue; background:azure; border:1px solid blue; border-radius:4px; cursor:pointer;"

    >
  13. </

    form

    >
  14. <br

    >
  15. <h2

    style

    =

    "color:blue; font-family:cursive;"

    >

    Crc32 Result</

    h2

    ><br

    >
  16. <input

    type

    =

    "text"

    value

    =

    "<?php if(isset($_POST['crc32_convertion'])){ echo crc32($_POST['convert']); } ?>

    " style="padding:5px; text-align:center; border:1px solid blue; color:white; font-size:18px; background:#1982d1; cursor:not-allowed; width:480px; " readonly><br

    ><br

    >
  17. </

    div

    >
  18. </

    center

    >

  19. </

    body

    >
  20. </

    html

    >

Here's the result of the full source code above.
2_52.png


Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

338,631

338,639

Top