0

I have WordPress site and custom table in DB. I need an user can enter promocode in the form, submit it, script find URL in the table by this promocode and open this URL in new window. I insert this HTML in widjet

<form method="get" id="searchform" action="">
<input type="text" name="destination" id="destination" value="" />
<input type="submit" id="searchsubmit" value="GO" />
</form>

And insert this code in function.php

$q = $_GET["destination"];
$result = $wpdb->get_results( "SELECT url FROM mytable WHERE target = ".$q);
var_dump($result);

But how to open window?

Astraport
  • 1,239
  • 4
  • 20
  • 40

1 Answers1

1

You can do this task by doing ajax once you get success in that you can write the code for opening the website in new tab

Here is another option but i am not preferring this.

echo "<script> window.open(".$external_link.", '_blank') </script>";
     exit;
Akshay Shah
  • 3,391
  • 2
  • 20
  • 33